PyQt4.QtCore.pyqtSignal object has no attribute 'connect'

前端 未结 6 1042
别那么骄傲
别那么骄傲 2020-12-23 09:04

I\'m having issues with a custom signal in a class I made.

Relevant code:

self.parse_triggered = QtCore.pyqtSignal()

def parseFile(self):
    self.e         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-23 09:31

    I have recently started working with PySide (Nokia's own version of PyQt), and saw the exact same behaviour (and solution) with custom new-style signals. My biggest concern with the solution was that using a class variable to hold the signal would mess things up when I have multiple instances of that class (QThreads in my case).

    From what I could see, QtCore.QObject.__init__(self) finds the Signal variable in the class and creates a copy of that Signal for the instance. I have no idea what QObject.__init__() does, but the resulting Signal does proper connect(), disconnect() and emit() methods (and also a __getitem__() method), whereas the class Signal or standalone Signal variables created outside of a QObject-derived class do not have these methods and can't be used properly.

提交回复
热议问题