I am trying to implement a desktop application with PyQGIS 3. When I try to use openFeatureForm
to display the data of the selected layer object it shows an error, however when I use this code in the Python Console in QGIS it works correctly.
How can I use it for the application I'm doing outside of QGIS?
def info(self):
self.vlayer = QgsVectorLayer('provincias.shp', "Provincias", "ogr")
QgsProject.instance().addMapLayer(self.vlayer)
layer = self.vlayer
features = layer.getFeatures()
feat = layer.getFeature(2)
iface.openFeatureForm(layer, feat, True)
This is the console error :
Traceback (most recent call last):
File "D:/proyectos/catastroesp/catastro.py", line 111, in info
iface.openFeatureForm(layer, feat, True)
AttributeError: 'NoneType' object has no attribute 'openFeatureForm'