1. 使用QUiloader加载
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QApplication,QWidget
import sys
class ui_call(QWidget):
def __init__(self):
super().__init__()
self.ui = QUiLoader().load('calltest.ui')
if __name__ == '__main__':
app = QApplication(sys.argv)
window = ui_call()
window.ui.show() ### 注意
sys.exit(app.exec())
2. 调用py文件
from ui_calltest import Ui_Form
from PySide6.QtWidgets import QApplication,QWidget
import sys
class ui_call(QWidget):
def __init__(self):
super().__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = ui_call()
window.show()
sys.exit(app.exec())