In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to achieve python signal and slot disconnection and connection, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Disconnection and connection between signal and slot
Sometimes for some reason, you want to disconnect a signal from a slot function temporarily or permanently. That's what you're talking about.
Generally speaking, adding dis before connect means unbinding: disconnect.
Examples are as follows
From PyQt5.QtCore import QObject,pyqtSignalclass SignalClass (QObject): # declare a signal with no parameters signal1=pyqtSignal () # declare a signal with an int type parameter signal2=pyqtSignal (int) def _ init__ (self,parent=None): super (SignalClass Self). _ init__ (parent) # connects the signal1 signal to two slot functions self.signal1.connect (self.sig1Call) self.signal1.connect (self.sig2Call) # connects the signal2 signal to the signal 1 self.signal2.connect (self.signal1) # transmit signal self.signal1.emit () self.signal2.emit (1) # disconnects the relationship between the signal and the slot function self.signal1.disconnect (self.sig1Call) self.signal1 .disconnect (self.sig2Call) self.signal2.disconnect (self.signal1) # binding signal and slot function self.signal1.connect (self.sig1Call) self.signal2.connect (self.sig1Call) # signal Emission self.signal1.emit () self.signal2.emit (1) # output signal 1 Emission def sig1Call (self): print ('signal-1 emit') # output signal 2 Emission def sig2Call (self): print (' signal-2 Emit') if _ _ name__ = ='_ main__': signal=SignalClass ()
Thank you for reading this article carefully. I hope the article "how to disconnect and connect python signals and slots" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.