Reputation: 447
I have created to .ui files using QtDesigner and I load them into two seperate windows as show below
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__()
# Set up the user interface from Designer.
uic.loadUi("interface/UI/main.ui", self)
# Connect up the buttons
self.button_classes.clicked.connect(self.open_classes)
self.w = []
def open_classes(self):
self.w.append(PopupWindow(self))
self.w[-1].show()
class PopupWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__()
# Set up the user interface from Designer.
uic.loadUi("interface/UI/newclass.ui", self)
When I run the code in PyCharm in debug mode, the following error occurs, however this does not happen when the code is run normally
TypeError: ('Wrong base class of toplevel widget', (<class 'controllers.GUI.PopupWindow'>, 'QDialog'))
Upvotes: 4
Views: 17516
Reputation: 142641
You have QDialog
in message 'Wrong base class of toplevel widget', (<class 'controllers.GUI.NewClassWindow'>, 'QDialog')
so I think it expects QDialog
to create second window but you use QMainWindow
in class PopupWindowONE(QMainWindow):
In other words, check the class type of the .ui file you are going to initiate; if the class is a QDialog
then your python class needs to receive a QDialog
.
Upvotes: 11
Reputation: 379
I had a similar problem when using QDialog
but changed it to QMainWindow
and it worked.
Upvotes: 5