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

前端 未结 6 1035
别那么骄傲
别那么骄傲 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条回答
  •  Happy的楠姐
    2020-12-23 09:43

    I had the same exact problem as you.

    Try moving

    self.parse_triggered = QtCore.pyqtSignal()
    

    out of your constructor but inside your class declaration. So instead of it looking like this:

    class Worker(QtCore.QThread):
        def __init__(self, parent = None):
            super(Worker, self).__init__(parent)
    
            self.parse_triggered = QtCore.pyqtSignal()
    

    It should look like this:

    class Worker(QtCore.QThread):
        parse_triggered = QtCore.pyqtSignal()
    
        def __init__(self, parent = None):
            super(Worker, self).__init__(parent)
    

    This might not be at all what you are looking for, but it worked for me. I switched back to old-style signals anyways because I haven't found a way in new-style signals to have an undefined number or type of parameters.

提交回复
热议问题