当前位置:网站首页>Pyqt5 rapid development and practice 3.1 QT designer quick start
Pyqt5 rapid development and practice 3.1 QT designer quick start
2022-07-26 11:08:00 【Ding Jiaxiong】
PyQt5 Rapid development and actual combat
3. The first 3 Chapter Qt Designer Use
List of articles
3.1 Qt Designer Quick start
Qt Designer, namely Qt The designer , Is a powerful 、 Flexible visualization GUI Design tools , Can help us speed up the development of PyQt The speed of the program .Qt Designer It is specially used to make PyQt In the program UI Interface tools , It generates UI The interface is a suffix .ui The file of . This file is very simple to use , You can use the command to .ui File conversion to .py File format , And by others Python File reference .
Qt Designer accord with MVC( Model — View 1 controller ) Design patterns , Achieved the separation of display and business series .
Qt Designer Has the following advantages .
- Easy to use , Complex interface design can be completed by dragging and clicking , And you can preview and view the renderings at any time .
- transformation Python The documents are convenient .Qt Designer You can save the designed user interface as .ui file ,
install pyqt5designer
pip install pyqt5designer -i https://pypi.tuna.tsinghua.edu.cn/simple

To configure pycharm
Qtdesigner


PyUIC5
$FileName$ -o $FileNameWithoutExtension$.py
$FileDir$

pyrcc5

application

3.1.1 New main window
Click on


choice Main Window Templates
3.1.2 Introduction to the main areas of the window

forms → preview

Object viewer

View the list of objects placed in the main window
Property editor

Which provides a window 、 Control 、 Property editing function of layout
- objectName: Control object name
- geometry: Relative coordinates
- minimumSize: Minimum width 、 Height
- maximumSize: Maximum width 、 Height . If you want the size of the window or control to be fixed , Then you can put min、max Set the two properties to the same value .
- font: typeface
- cursor: cursor
- windowTitle: Window title
- windowsIcon/icon: Window icons / Control icon
- iconSize: Icon size
- toolTip: Prompt information
- statusTip: Taskbar display information
- text: Control text
- shortcut: Shortcut key
The signal / Slot Editor 、 Action editor 、 Resource browser

Where in the signal / In the slot editor , You can add custom signal and slot functions for the control , Edit the signal and slot functions of the control .
In the asset browser , You can add pictures to controls
3.1.3 see UI file
use Qt Designer The interface file of tool design defaults to .ui file , Describes the property list and layout display of controls in the window .ui The contents contained in the document are in accordance with XML ( Extensible markup language ) Format processing .


The message is consistent . With Qt Designer, Developers can develop and design program interfaces faster , Avoid the tedious writing with pure code , So you don't have to worry about the bottom-level code implementation .
3.1.4 take .ui The file is converted to .py file


Put... On the command line .ui The file is converted to .py file , A little
pyuic5 -o firstMainwin.py firstMainwin.ui
3.1.5 Interface is separated from logic
Create a new one CallFirstMainWin.py file , Inherit the main window of the interface file

import sys
from PyQt5.QtWidgets import QApplication , QMainWindow
from firstMainWin import *
class MyMainWindow(QMainWindow,Ui_MainWindow):
def __init__(self,parent = None):
super(MyMainWindow,self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
myWin = MyMainWindow()
myWin.show()
sys.exit(app.exec_())
function CallFirstMainWin.py

边栏推荐
猜你喜欢
随机推荐
微信公众号开发 获取openid时报错40029 invalid code 问题的解决
easyui04
Bash shell学习笔记(五)
数据可视化-《白蛇2:青蛇劫起》(2)
静态路由和动态路由
Synchronized与ReentrantLock
Analysis of C # delegation and anonymous method
0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
Pytest execution rules_ Basic usage_ Common plug-ins_ Common assertions_ Common parameters
Bash shell learning notes (II)
Drbl diskless startup + Clonezilla network backup and restore system
MySQL锁机制
Fragment lazy load
Bash shell learning notes (V)
easyui02
Traversal recursion + iteration of binary tree
Bash shell learning notes (III)
【转载】多元高斯分布(The Multivariate normal distribution)
AuthorizingRealm简介说明
MySQL learning notes









