[Interest] QML blocking popup menu

Martin Haker martin.haker at gmail.com
Tue Jun 11 14:26:44 CEST 2013


Hi everyone,

in the process of porting an existing widget-based application to QML I
would like to implement a blocking popup menu (similar to a context menu
using QMenu), i.e. code execution waits for the user to provide input or
dismiss the popup menu.

I have created a mockup (find it attached) with three different
implementations:

(0) - non-blocking (shows the desired behavior)
(1) - blocking using QEventLoop (when the popup is dismissed setting
mouse.accepted = false should allow further processing of the event by
other items below the popup; this fails, however)
(2) - blocking using busy waiting and QCoreApplication::
processEvents() (same effect as in (1))

The three implementations can be activated in Popup.cpp. There is a #define
IMPLEMENTATION at the very top (that does make the code a bit harder to
read, sorry). Currently implementation (0) is active.

The mockup shows a green and a red square. The following should happen:

(1) - Clicking a square creates a popup with the respective color.
(2a) - Clicking the popup lets the popup disappear (user input).
(2b) - Clicking the same square or the white background lets the popup
disappear (cancel).
(2c) - Clicking the other square lets the popup disappear (cancel) and
instantly creates a popup for the other square (mouse.accepted = false
takes effect)

The case (2c) fails for the other two implementations and one has to click
the other square twice in order bring up the popup. Interestingly, the item
receives the OnPressed event, but neither the OnClicked nor the OnReleased
event.

Any ideas on how to solve this? My preferred implementation would be (1).

Thanks in advance for any help.
Best regards
Martin


PS: If have tested the mockup on Mac OS. There is an #ifdef in Popup.cpp to
set the file path for Popup.qml. I hope I have set it correctly for anyone
testing on another OS.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130611/2fb8a816/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BlockingPopup.zip
Type: application/zip
Size: 24132 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130611/2fb8a816/attachment.zip>


More information about the Interest mailing list