0

I want to add a custom widget I have created in qt designer into my mainwindow. Preferably both mainwindow and widget can be created in qt designer and used as is (.ui file)

Because I couldn't get the widget.ui file working, I tried converting it to python but couldn't get it implemented without various bugs (argument errors, what to use as promoted class name / header file, etc.).

Unfortunately every other guide I found online for creating custom widgets has different structure to the one pyuic5 produces:

pyuic5 result:

class Ui_Form(object):

    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)

        # Rest of design...

online guide result (pure python):

class PurePythonWidget(QtWidgets.QWidget):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.layout = QtWidgets.QGridLayout()
        self.setLayout(self.layout)

        # Rest of design...

How can I adapt my code to preferably work with a .ui file or a pyuic5 file. Because almost every approach is slightly different please provide the entire sourcecode too.

In the final product I wan't to use this to fill a Scroll Area with these widgets containing different data. A better approach may resolve this question in a different way.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
jo_kil
  • 1
  • 2
  • Have you read the official guidelines about [using Designer](https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html)? – musicamante Jul 29 '20 at 13:40
  • @musicamante I did but it didn't prove very helpful – jo_kil Jul 29 '20 at 14:38
  • What do you mean? It didn't work or you didn't understand it? In the first case, edit your post with the code you've tried, otherwise specify what was not clear about it. – musicamante Jul 29 '20 at 14:40

0 Answers0