TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict)
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict)
我的代码有什么问题?我正在尝试将我的 UI 文件与 python 连接起来。我几乎可以肯定所有事情,但我无法定义哪里出了问题。
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.uic import loadUiType
ui = loadUiType('main.ui')
class MainApp(QMainWindow, ui):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUI(self)
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exex_()
if __name__ == '__main__':
main()
我不确定 UI 文件加载的 'inheritance' 风格应该如何工作。但是,这应该可以满足您的要求:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.uic import loadUi
class MainApp(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
loadUi('main.ui', self)
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()
我的代码有什么问题?我正在尝试将我的 UI 文件与 python 连接起来。我几乎可以肯定所有事情,但我无法定义哪里出了问题。
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.uic import loadUiType
ui = loadUiType('main.ui')
class MainApp(QMainWindow, ui):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUI(self)
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exex_()
if __name__ == '__main__':
main()
我不确定 UI 文件加载的 'inheritance' 风格应该如何工作。但是,这应该可以满足您的要求:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.uic import loadUi
class MainApp(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
loadUi('main.ui', self)
def main():
app = QApplication(sys.argv)
window = MainApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()