Issue with using 'promote to' in QtDesigner with PyQt5



  • I've created a object called ImageViewer that inherits from QStackedImage. I wanted to use the 'promote to' function in QtDesigner to change my current QStackedImage to a ImageViewer object. I was a little confused about it asking for a header file in python for a while but eventually I figured it out. It imported correctly and even created a .pyc file which means it imported and compiled it correctly. The problem arises in my code when I try to set up the UI. A snippet is shown below.

    qtCreatorFile = "EITDaq2.ui"
    Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)

    class DAQView(QtWidgets.QMainWindow, Ui_MainWindow):

    def __init__(self, model):
        # qt required window init stuff (from double inheritance)
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)
    

    On the command 'self.setupUi(self)' I get the error:

    self.setupUi(self)
    File "<string>", line 257, in setupUi
    TypeError: __init__() takes exactly 1 argument (2 given)
    

    It seems like I'm passing it 1 parameter but maybe when I promote the new ImageViewer object into the ui file it makes it into a sister widget to the main window instead of a child widget so it's like passing in two parameters to the ui builder. I've checked all over the forum and haven't found anything. Much appreciation for any insight.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.