6

I've got PyQt4 with a python 3.4 and there is this strange bug occurring. Whenever I try to call btn.clicked.connect(), Pycharm will throw this error:

Cannot find reference "connect" in "function".

So for example:

btn = QtGui.QPushButton("Quit", self)
btn.clicked.connect(QtCore.QCoreApplication.instance().quit)

will throw this error. How? Do I have missing files?

Rok Dolinar
  • 976
  • 3
  • 13
  • 29

1 Answers1

4

According to Events and Signals in PyQt4 - PyQt4 Tutorial - ZetCode:

PyQt4.5 introduced a new style API for working with signals and slots.

QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'),self.onClicked)

This is the old style API.

button.clicked.connect(self.onClicked)

The new style adheres more to the Python standards.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
  • 14
    Eh, what "works" here? Python does execute this correctly, yes. But Pycharm and it's Python analysis does still not correctly handle `button.clicked.connect(self.onClicked)`. The warning persists, because it can not defer the type of `clicked`. Any hints here how to make this work? – nerdoc Dec 01 '16 at 21:31