Thank you; I shall answer inline also: -----Original Message----- >From: Cristián Maureira-Fredes <cristian.maureira-fre...@qt.io> >To: pyside@qt-project.org >Subject: Re: [PySide] Distinguishing QEvents originating in PySide2 from those originating in C++
>Hello, >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 ? Not quite; that example has to do with wrapping a C++ class using Shiboken for use from Python. In our case, we provide an edit window where users can write (or paste) their own Python scripts which create QDialogs and other widgets, then we pass the scripts internally to python27.dll which executes the scripts and pops up the windows. Think of it as if we'd written a very simple Python IDE, and we're running the Tetrix.py example from within it. We want to be able to distinguish events from the Tetrix window and events from other, native C++ windows that we pop up ourselves. > 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: https://doc.qt.io/qt-5/qobject.html#objectName-prop > > 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. We have little control over what our customers will write, but we know that if they write something that changes our application's data while we're in the process of working on it, and it crashes the application, then they'll blame us! Hence what we really want to do is to ensure that ALL QEvents from our C++-generated windows are processed, and the system put into a stable state, before ANY of the events from PySide2-generated windows are processed. Our best ideas so far are: 1. Similar to what you suggest, give all of our own widgets names that begin with some code that the customer can't guess, so we can recognise all our widgets and others must be a customer's. 2. Identify a widget's parentage: for example, if all of our widgets belong to an inheritance tree that goes up to the application's QMainWindow, then any that don't must be the customer's - but can we rely on this? How is a PySide2 window parented? But both these seem rather inelegant. We also thought of forcing a QEventFilter upon all the PySide-generated widgets, but we can't see a way of doing this. Therefore we'd be grateful for any and all advice. >Cheers -- >Dr. Cristian Maureira-Fredes >R&D Manager _______________________________________________ PySide mailing list PySide@qt-project.org https://lists.qt-project.org/listinfo/pyside