PyQt---How to run the GUI interface created by QtDesigner in pycharm?

Continue the operation of the previous article.

1. Create a new py file in the running window and enter:

import sys
import MainWinHorizontalLayout
from PyQt5.QtWidgets import QApplication,QMainWindow

if __name__=='__main__':
    app=QApplication(sys.argv)     #创建一个桌面应用程序
    mainWindow=QMainWindow()       #创建主窗口
    ui=MainWinHorizontalLayout.Ui_MainWindow()
    ui.setupUi(mainWindow)    #调用Main...中的setupUi创建控件,参数指的是在那个窗口添加控件
    mainWindow.show()
    sys.exit(app.exec_())

2. Running results:
Insert picture description here

Guess you like

Origin blog.csdn.net/Forest_2Cat/article/details/105583639