I am new to Python. I have created a button using PyQt and want to call two separate functions by clicking the same button
QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial,self.trial2)
You can just connect the signal twice, like:
QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial)
QtCore.QObject.connect(self.start, QtCore.SIGNAL('clicked()'), self.trial2)
Both functions will be called when the signal is emitted. According to the document:
If a signal is connected to several slots, the slots are activated in the same order in which the connections were made, when the signal is emitted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.