小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

pyqt4中創(chuàng)建自定義signal的方法

 Tech-d 2013-01-29
class SSHThread(QThread):
    def __init__(self, hostname = '', renderList = [], tabLabelText = 'L0001', parent = None):
        """ constructor"""
        ...omit...
        #a new custom signal to set string to textEdit
        self.editSignal = pyqtSignal(QString, QString)
         ...omit...

    def run(self):
          """ emit the new signal"""
          ... omit ...
          self.emit(SIGNAL('editSignal(QString, QString)'), QString("param1"), QString("param2"))
          ... omit ...

...... omit ......
def executeBtn(self):
      """ connect the new signal and a slot function"""
      QObject.connect(self.sshThread, SIGNAL('editSignal(QString, QString)'), self.on_textEdit_update)
      ... omit ...

def on_textEdit_update(self, param1, param2):
       """ the slot function"""
       ... omit ...


================================================

20151223補充一個完整例子,來源:

http:///questions/3891465/how-to-connect-pyqtsignal-between-classes-in-pyqt

from PyQt4 import QtCore

class Pot(QtCore.QObject):

    temperatureRaisedSignal = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        QtCore.QObject.__init__(self)
        self.temperature = 1

    def Boil(self):
        self.temperatureRaisedSignal.emit()
        self.temperature += 1

class Thermometer():
    def __init__(self, pot):
        self.pot = pot
        self.pot.temperatureRaisedSignal.connect(self.temperatureWarning)

    def StartMeasure(self):
        self.pot.Boil()

    def temperatureWarning(self):
        print("Too high temperature!")

if __name__ == '__main__':
    pot = Pot()
    th = Thermometer(pot)
    th.StartMeasure()



    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多