This page describes how to use Qt Creator to create GUIs for your PySide software. You will need Qt Creator to design and modify your interface (ui file)
Qt Designer is used to create UI files.
In Qt Creator, create a new form, select "Main Window" for the template. And save as "mainwindow.ui". Add a Qlabel to the center of the central widget.
Your file (mainwindow.ui) should look something like this:
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>82</width> <height>64</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Hello World!</string> </property> </widget> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>82</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
Now, using PySide2, we will download the ui file and run our application:
# main.py import sys from PySide2.QtUiTools import QUiLoader from PySide2.QtWidgets import QApplication from PySide2.QtCore import QFile if __name__ == "__main__": app = QApplication(sys.argv) file = QFile("mainwindow.ui") file.open(QFile.ReadOnly) loader = QUiLoader() window = loader.load(file) window.show() sys.exit(app.exec_())