当前位置:网站首页>Pyqt5 rapid development and practice 3.4 signal and slot correlation
Pyqt5 rapid development and practice 3.4 signal and slot correlation
2022-07-26 16:42:00 【Ding Jiaxiong】
PyQt5 Rapid development and actual combat
List of articles
3. The first 3 Chapter Qt Designer Use
3.4 The signal is associated with the slot
The signal (signal) Slot (slot) yes Qt The core mechanism of . After creating the event loop , Communication between objects can be realized by establishing the connection between signal and slot . When the signal is transmitted (emit) when , The connected slot function will execute automatically . stay PyQt 5 in , Signals and slots pass through QObject.signal.connect() Connect .
All from QObject Class or its subclasses ( Such as QWidget) Derived classes can contain both signals and slots . When an object changes its state , The signal is sent out by this object . Slot for receiving signal , But they are ordinary object member functions . Multiple signals can be connected to a single slot , A single signal can also be connected to multiple slots . All in all , Signals and slots build a powerful control programming mechanism .
3.4.1 Simple introduction


This means that ” close window “ When the button is clicked, it will be emitted clicked The signal , This signal will be Form Slot function of form close() capture , And trigger the close Behavior .



Create a new file displayed in the call window CallMainWinSignalSlot01.py
import sys
from PyQt5.QtWidgets import QApplication,QMainWindow
from MainWinSignalSlog01 import Ui_Form
class MyMainWindow(QMainWindow , Ui_Form):
def __init__(self,parent = None):
super(MyMainWindow, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
from pyqt5_plugins.examples.exampleqmlitem import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
myWin = MyMainWindow()
myWin.show()
sys.exit(app.exec())

Click button , The window closed , Program exit .
3.4.2 Advance quickly
utilize “ Signal and slot editing window ” Carry out signal adjustment and other operations .

Use a check box to control the display of a label and a text edit Of the available .


Key code

Eric This IDE One called “ Generate dialog code ” The function of , Signals and slots can also be generated .
边栏推荐
猜你喜欢

Pat grade a 1044 shopping in Mars

The difference between anonymous methods and lambda expressions

Difference between C event and delegation

Acl-ijcai-sigir top conference paper report meeting (AIS 2022) Note 3: dialogue and generation

2022-2023 信息管理毕业设计选题题目推荐

RE9: read the paper deal inductive link prediction for nodes having only attribute information

Marketing guide | several common micro blog marketing methods

About the idea plug-in I wrote that can generate service and mapper with one click (with source code)

2022牛客暑期多校训练营1(ACDGIJ)

Tdengine landed in GCL energy technology, with tens of billions of data compressed to 600gb
随机推荐
视频媒介video
公安部发出暑期旅游客运交通安全预警:手握方向盘 绷紧安全弦
Replicationcontroller and replicaset of kubernetes
Alibaba side: analysis of ten classic interview questions
研发效能的道与术 - 道篇
[arm learning (9) ARM compiler understanding learning (armcc/armclang)]
Win11系统如何一键进行重装?
Matlab论文插图绘制模板第40期—带偏移扇区的饼图
微信小程序---网络数据请求
Probe of kubernetes
Pat grade a 1049 counting ones
Vlang's way of beating drums
A firefox/chrome plug-in that visualizes browser history
如何保证缓存和数据库一致性
Digital intelligence transformation, management first | jnpf strives to build a "full life cycle management" platform
How to write unit tests
Wechat applet - network data request
Reflections on the mystery of Silicon Valley
【Flutter -- 进阶】打包
What is the complexity often said during the interview?