@kiyoshi7 said in (Pyqt) create instances of widgets generated in designer:
i get this error, that I dont know how to fix.
As the error message states, your self.gridLayout.addWidget(self.widget, 0, 0, 1, 1) call does not match any available overload of QGridLayout.addWidget(). And it even shows you which ones are available, what the types of the arguments are, and which argument is causing it a problem!
The Ui_... classes generated from Designer are not widgets. Have a look in the generated ui_...py files to see, then it's not such a mystery. They are wrappers which set up a widget passed as an argument. So soemthing like:
self.graph1 = QtWidgets.QFrame()
ui = GraphTemplate.Ui_Form()
ui.setupUi(self.graph1)
self...addWidget(self.graph1, 0, 0, 1, 1)
However, this corresponds to the first example code in https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html. You would be better adopting the pattern in the second or third examples there. Where, for each .ui form you design you edit your .py file (not ui...py) to create a dedicated class for the form and use that as the widget.
I haven't got time to go through and show exact code. You'll need to understand and follow the example, or find some online.