PySide6 NameError: name 'SLOT' is not defined in QTimer example documentation
-
wrote on 8 Jan 2023, 11:06 last edited by Erriez 1 Aug 2023, 14:33
PIP PySide 6.4.1 QTimer documentation contains the following example:
from PySide6.QtWidgets import QApplication from PySide6.QtCore import QTimer import sys if __name__ == "__main__": app = QApplication([]) QTimer.singleShot(600000, app, SLOT(quit())) ... sys.exit(app.exec())
When running the example, it generates the following error:
Traceback (most recent call last): File "qtimer_singleshot.py", line 8, in <module> QTimer.singleShot(600000, app, SLOT(quit())) NameError: name 'SLOT' is not defined
The function prototype is
static PySide6.QtCore.QTimer.singleShot(msec, receiver, member)
where the last argumentmember
is astr
. Changing this line toQTimer.singleShot(10, app, 'quit()')
generates aexit code 139 (interrupted by signal 11: SIGSEGV)
.I assume the example in the documentation is incorrect. What is the correct usage?
-
PIP PySide 6.4.1 QTimer documentation contains the following example:
from PySide6.QtWidgets import QApplication from PySide6.QtCore import QTimer import sys if __name__ == "__main__": app = QApplication([]) QTimer.singleShot(600000, app, SLOT(quit())) ... sys.exit(app.exec())
When running the example, it generates the following error:
Traceback (most recent call last): File "qtimer_singleshot.py", line 8, in <module> QTimer.singleShot(600000, app, SLOT(quit())) NameError: name 'SLOT' is not defined
The function prototype is
static PySide6.QtCore.QTimer.singleShot(msec, receiver, member)
where the last argumentmember
is astr
. Changing this line toQTimer.singleShot(10, app, 'quit()')
generates aexit code 139 (interrupted by signal 11: SIGSEGV)
.I assume the example in the documentation is incorrect. What is the correct usage?
-
@Erriez
Sadly many of the PySide examples are copied literally from C++ and are incorrect. I believe the correct call here for PySide6 is (untested)QTimer.singleShot(600000, app.quit)
wrote on 9 Jan 2023, 18:56 last edited by@JonB Thanks a lot for your help. Your code works perfect! It is really that simple.
I've created PYSIDE-2182 to update the documentation.
1/3