How to cause a modeless dialog to block input only to his direct parent (but not to any other windows), as if it was modal?
-
Hi,
I'm developing a new version of an application, called CP2130 Commander, which is able to communicate with several CP2130-based devices. Currently, although it has the capability of communicating with several devices at the same time, the application is unable to do so because the progress dialogs are modal.
Basically, what happens is that the main window gives the user the ability to open several devices at the same time, by opening one device window instance per device opened. Each device window is then able to control the respective device, and through such windows it is possible to perform SPI transfers. The progress dialog is shown when an ongoing SPI transfer takes more than 500ms. So far, so good.
The problem is that the progress dialog blocks input to every other window. I can make it modeless, but then it won't block input to its parent window, which is the device window instance from where it was opened. The idea is for it to be modeless, while still blocking input only to its immediate parent window, as if it was modal. Is it possible? Can I install an event filter? Or is there any other, more correct way, to do this?
By the way, if you wish to see some code, pertaining the ongoing development version: https://github.com/bloguetronica/cp2130-com/tree/v4.0.
Kind regards, Samuel Lourenço
-
You can enable/disable UI event handling using the "enabled" property (that works both for widgets and QML items).
Whether it's a good UI design choice is another question. -
Thanks! However, wouldn't that gray out the parent window? It is kind of what I want, but the disabled aspect, even if only momentarily, may send the wrong message to the user.
-
Hi and welcome to devnet,
Is your dialog tied to the "device" widget or is it to the window containing your device widget ?
-
@SGaist said in How to cause a modeless dialog to block input only to his direct parent (but not to any other windows), as if it was modal?:
Hi and welcome to devnet,
Is your dialog tied to the "device" widget or is it to the window containing your device widget ?
Hi and thanks! There is no device widget per se, but there is a device window. I would say that the progress dialog, currently modal but soon to be modeless (I hope) is tied to the device window. The device window is the parent of the progress dialog.
-
Thanks! However, wouldn't that gray out the parent window? It is kind of what I want, but the disabled aspect, even if only momentarily, may send the wrong message to the user.
@Samuel-Lourenco said in How to cause a modeless dialog to block input only to his direct parent (but not to any other windows), as if it was modal?:
Thanks! However, wouldn't that gray out the parent window? It is kind of what I want, but the disabled aspect, even if only momentarily, may send the wrong message to the user.
I don't believe "enabled" has visual cues, but that might depend on the platform.
However, if memory serves, the enabled property propagates to children. So if the progress dialog is a child of the device window, disabling the device window would also block input into the progress dialog itself (e.g. to a "cancel" button)EDIT: That said, the "enabled" flag (on the platform side) is what modal dialogs (at least on the Windows platform) actually use to disable UI input to all other windows.