I am creating a plugin for QGIS but am having trouble with the Qt components. I have used Plugin Builder and Qt designer to create all necessary files for the plugin. I want to use a QStackedWidget inside my QDialog and I can open the dialog just fine when I don't try to access the "pages" (or widgets) of the stacked widget. But I am getting an error when trying to reach the pages/objects located inside the pages of a stacked widget from my code.
Simple code example:
def __init__(self, iface): self.dlg = Dialog() self.stackedWidget = self.dlg.stackedWidget self.dlg.stackedWidget.page.pushButton.clicked.connect(self.func) def func(self): :code that does some stuff:
Returns the error: AttributeError: 'QStackedWidget' object has no attribute 'page'
Similarly if I try to work with just a stacked widget not inside a QDialog (again opens just fine without the code that causes errors) I get the same kind of error.
def __init__(self, iface): self.stackedWidget = StackedWidget() self.page = self.stackedWidget.page self.page.pushButton.clicked.connect(self.func) def func(self): :code that does some stuff:
Returns the error: AttributeError: 'QWidget' object has no attribute 'pushButton'
I am not sure what I am doing wrong or what is causing the error but will of course provide whatever code/information that might be needed to help me solve this problem.
I am thankful for whatever help you can provide!