gpt4 book ai didi

python - PyQt 没有 button.clicked.connect 功能?

转载 作者:太空狗 更新时间:2023-10-30 00:06:24 60 4
gpt4 key购买 nike

我有 PyQt4 和 python 3.4,但出现了这个奇怪的错误。每当我尝试调用 btn.clicked.connect() 时,Pycharm 都会抛出此错误:

Cannot find reference "connect" in "function".

例如:

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

会抛出这个错误。如何?我有丢失的文件吗?

最佳答案

根据 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.

关于python - PyQt 没有 button.clicked.connect 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33131569/

60 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com