0
我創建使用QtDesigner文件,我把它們裝入兩個單獨的窗口顯示爲以下PyQt5:類型錯誤:「錯誤的基類頂級部件的」
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)
當我運行在PyCharm代碼.UI調試模式下,會出現以下錯誤,當代碼正常運行
TypeError: ('Wrong base class of toplevel widget', (<class 'controllers.GUI.PopupWindow'>, 'QDialog'))
當您在console/terminal/cmd.exe/powershell中運行它時是否收到錯誤消息?添加有問題的完整錯誤消息。 – furas
@furas當我只是正常運行代碼時,沒有錯誤,但是如果我在PyCharm中以調試模式運行代碼,我得到一個類型錯誤,我已經添加到問題 – Ronikos
你有消息''錯誤的基類('class'controllers.GUI.NewClassWindow'>,'QDialog'))''所以我認爲它期望你使用'QDialog'創建第二個窗口,但是你可以在類PopupWindowONE(QMainWindow)中使用'QMainWindow': ' – furas