user4175226
user4175226

Reputation: 23

wrong constructor argument type, PySide

Well I can't figure out this issue, I am tryinf to fix something more complicated, and suddenly python came up with this:

class MainWidget(QWidget):

    def __init__(self, parent=None):            
        super(MainWidget,self).__init__(parent)
        self.initUI()

...
class MainWindow(QMainWindow):   

    def __init__(self, parent=None):        
        super(MainWindow, self).__init__(parent)        
        self.mainWidget = MainWidget(MainWindow)

and my IDE is saying that:

File "/home/maze/Develop/StartApp/startapp.py", line 47, in __init__
    super(MainWidget,self).__init__(parent)
TypeError: 'PySide.QtGui.QWidget' called with wrong argument types:
  PySide.QtGui.QWidget(Shiboken.ObjectType)
Supported signatures:
  PySide.QtGui.QWidget(PySide.QtGui.QWidget = None, PySide.QtCore.Qt.WindowFlags = 0)

I think, before it was working that way... Could You show me whats it about? Thanks for Your time.

Upvotes: 1

Views: 4200

Answers (1)

alexisdm
alexisdm

Reputation: 29896

You are calling the MainWidget constructor with an object type as parameter instead of an object instance in the constructor of MainWindow.

You should have:

self.mainWidget = MainWidget(self)

instead of:

self.mainWidget = MainWidget(MainWindow)

Upvotes: 2

Related Questions