Ron*_*kos 4 python pyqt python-3.x pyqt5
我已经使用 QtDesigner 创建了 .ui 文件,并将它们加载到两个单独的窗口中,如下所示
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)
Run Code Online (Sandbox Code Playgroud)
当我在 PyCharm 中以调试模式运行代码时,出现以下错误,但是当代码正常运行时不会发生这种情况
TypeError: ('Wrong base class of toplevel widget', (<class 'controllers.GUI.PopupWindow'>, 'QDialog'))
Run Code Online (Sandbox Code Playgroud)
fur*_*ras 11
你有QDialog消息,'Wrong base class of toplevel widget', (<class 'controllers.GUI.NewClassWindow'>, 'QDialog')所以我认为它期望QDialog创建第二个窗口,但你QMainWindow使用class PopupWindowONE(QMainWindow):
换句话说,检查您要启动的 .ui 文件的类类型;如果类是 aQDialog那么你的 python 类需要接收一个QDialog.
| 归档时间: |
|
| 查看次数: |
16274 次 |
| 最近记录: |