8000 signal.connect() TypeError in pyqt5 when signal has an argument · Issue #388 · mottosso/Qt.py · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
signal.connect() TypeError in pyqt5 when signal has an argument #388
Open
@eyeteajay

Description

@eyeteajay

Using this code example:

import logging
from Qt import QtCore
from Qt import QtWidgets

class MainWind(QtWidgets.QMainWindow):
    willclose = QtCore.Signal(int)
    
    def __init__(self, *args, **kw):
        super(MainWind, self).__init__(*args, **kw)
        but = QtWidgets.QPushButton("hi")
        self.setCentralWidget(but)
    
    def closeEvent(self, evt):
        closecode = 10
        logging.info("will close '%s': %s: %s", self.objectName(), closecode, self)
        self.willclose.emit(closecode)
        return super(MainWind, self).closeEvent(evt)

class Runner(object):
    def __init__(self, wind):
        wind.willclose.connect(self.didclose)
        self._wind = wind
    
    @QtCore.Slot(int)
    def didclose(self, closecode):
        logging.info("didclose signal called with: %r", closecode)
    
    def run(self):
        self._wind.show()
        exitcode = QtWidgets.QApplication.instance().exec_()
        return exitcode

logging.basicConfig(level=logging.DEBUG)
app = QtWidgets.QApplication([])
wind = MainWind()
r = Runner(wind)
r.run()

produces a TypeError when trying to connect a signal using python3 & PyQt5:
TypeError: connect() failed between MainWind.willclose[int] and didclose()

However, the same code runs fine using python3 & PySide2.
An undecorated didclose() method will also run using PyQt5, and a slot method that takes no arguments will also run.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0