Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.2.3
-
None
Description
In following script, the event filter is destroyed by gc when create_label() returns and therefore will not work.
If the event filter is defined as global, it works as expected.
It should be better to keep a reference to filter object in installEventFilter().
import sys from PySide6.QtCore import QObject from PySide6.QtWidgets import QApplication, QLabel class Filter(QObject): def __del__(self): print('del') def eventFilter(self, obj, event): print(event) return False def create_label(): label = QLabel('hello') filter_ = Filter() label.installEventFilter(filter_) return label app = QApplication(sys.argv) label = create_label() label.show() sys.exit(app.exec())
Attachments
Issue Links
- relates to
-
PYSIDE-1737 QCoreApplication::installNativeEventFilter doesn't keep a reference to the event filter
- Reported
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-1807 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
394080,1 | QObject.installEventFilter take ownership of filter | dev | pyside/pyside-setup | Status: ABANDONED | -1 | 0 |