Consider the code below:
#!/usr/bin/env python
from PyQt4 import QtCore, QtGui
import os,sys
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.listWidget = QtGui.QListWidget(None)
self.setCentralWidget(self.listWidget)
if __name__ == '__main__':
app = QtGui.QApplication (sys.argv)
mainWin = MainWindow ()
mainWin.show ()
sys.exit (app.exec_())
Works ok. Now if I add a dummy class (that inherits from a QtGui module's class) in the global scope ...
class MainWindow(QtGui.QMainWindow):
... # unchanged
class MyWidget(QtGui.QWidget):
def __init__(self):
super(MyWidget, self).__init__()
if __name__ == '__main__':
... # unchanged
... when i launch the script i get the error:
TypeError: argument 1 of QMainWindow.setCentralWidget() has an invalid type
This error message is cryptic for me as i can't connect it to the modification done. Do you have an idea what could be the source of this error?