We have a PyQt4/PySide Qt4 video player app that has QToolButton object in the GUI with an associated QMenu, added with QToolButton#setMenu(). Currently, when the user interacts with the menu, it takes over the event loop and video playback stops. The event loop takeover occurs in the private QToolButtonPrivate::popupTimerDone().
We’d like to rewrite/modify QToolButton to not be modeless, but there doesn’t appear to be any easy choices:
- Copy and modify QToolButton in C++ and then use PyQt4 or PySide’s C++ wrapping to wrap the class for Python. Easier, but now our build system needs to compile a C++ class and know which environment it’s running in, PySide or PyQt4.
- Completely rewrite QToolButton in Python, so it would subclass QAbstractButton, and make the modifications. A decent amount of code to rewrite and maintain.
- In Python, subclass QToolButton and override where necessary. This seems nice, but looking at the internal state that QToolButtonPrivate::popupTimerDone() references, we would be mostly rewriting the entire thing anyway.
Are there any other ideas?
I would recommend looking into using the QToolButton.clicked signal with the QMenu.popup method vs. the setMenu – that may break the modality.
I tried setting up an example for you – but it doesn’t block the QMovie…so maybe you can use this example to test the different options for a video player vs. a Qmovie and see if it still blocks your event loop: