Details
-
Technical task
-
Resolution: Unresolved
-
P2: Important
-
f762506f9 (dev), 247c14cf3 (6.5), 95cb332c3 (tqtc/lts-6.2)
Description
Document about why dynamically adding signals and slots (on signal connection for instance) will cause issues both in Qt and PySide, and might lead to hard-to-debug issues and crashes.
Main takeaways:
1) Always decorate slots with @QtCore.Slot()
2) Don't dynamically add / remove signals or slots after a connection is made to any signal or slot.
3) Do not create signals in __init__ methods, the mySignal = QtCore.Signal() definitions should be as class members of the custom class.
2023 addition :
4) For QObject's registered with QML, always use @Slot() for invokable methods, the automatic method registration can fail (PYSIDE-2436)
Also "Add a logging category to libpyside" bd6a2f1f880effb95ea3e42f52d06f0730103a03 https://codereview.qt-project.org/c/pyside/pyside-setup/+/426960 adds a logging category to get respective warnings by
export QT_LOGGING_RULES="qt.pyside.libpyside.warning=true".
Attachments
Issue Links
- relates to
-
PYSIDE-2436 Python-based QML element as a QML component doesn't trigger non-slot connections
- Closed
-
PYSIDE-2033 Signals are not ordered correctly with multiple inheritance
- Closed
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-463 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
192546,2 | hellogl.py: Fix signal creation | 5.6 | pyside/examples | Status: MERGED | +2 | 0 |
499432,2 | Documentation/Signal slot tutorial: Recommend to use @Slot always | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
499483,2 | Documentation/Signal slot tutorial: Recommend to use @Slot always | 6.5 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
499484,2 | Documentation/Signal slot tutorial: Recommend to use @Slot always | tqtc/lts-6.2 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |