[PySide] Distinguishing QEvents originating in PySide2 from those originating in C++
Cristian.Maureira-Fredes at qt.io
Tue Mar 10 17:42:15 CET 2020
I will answer inline:
On 3/10/20 2:27 PM, Stephen Morris wrote:
> We’re writing an application in which we create numerous QWidgets of our
> own in C++, while also embedding a Python interpreter which allows
> customers to write and execute their own scripts using PySide2 from
> within our application.
I guess this is based on the "Scriptable Application" example ?
> When they write PySide2 scripts which open up windows, and those windows
> contain widgets which create QEvents, they are processed as part of the
> same main event loop as our C++-generated windows.
Yes, because there should be only one Q*Application instance.
> It would be very helpful if we could apply an event filter which would
> allow us to intercept events that originate from the PySIde2-generated
> windows, to make us aware if end-users trigger events from their PySide2
> windows which may affect the state of our application’s data.
> Is there a way of doing this? Preferably without having to override
> QCoreApplication::notify(), since that approach is deprecated in Qt6.
Maybe you can try to name all the QObjects that might interact with
QEvent, so you can somehow check on the names with a certain prefix
to filter them:
I'm unaware how other people out there is filtering such things,
or maybe the way of allowing the user to create their own things
from Python is restricted to a limited amount of widgets on the
main C++ application.
Dr. Cristian Maureira-Fredes
The Qt Company GmbH
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Charlottenburg, HRB 144331 B
More information about the PySide