Unsolved How to avoid Mouse events propagation
-
Hi,
I am having a QML which is having a few buttons like a HOME button whose action when pressed will go to Home screen and a Load Button to load the values from a QAbstractItemModel to the QML.
The operation is such that when a load button is pressed, the QML will display a confirmation dialog box (I created on my own) prompting the user whether to load the values or not. Based upon the Yes response the QML will load the values from the backend to the UI. For this it will take some time.
Issue: While loading the values, if the user presses the HOME button, the mouse event is queued and after loading the values, the screen is automatically switched to HOME screen which I do not expect to happen. How to avoid this from happenening ?
NOTE: While displaying confirmation dialog, I am disabling the whole screen with Mouse Area Fill and setting the propagateMouseEvents to false, but still the mouse click is propagated and queued and the HOME screen is automatically navigated due to press.
-
While loading the values, if the user presses the HOME button, the mouse event is queued and after loading the values, the screen is automatically switched to HOME screen which I do not expect to happen. How to avoid this from happenening ?
What if you disable the
HOME
button during this process ? -
@AbuFahima, If i understood your right you load values in the same thread as UI, don't you?
In this case you should swap <hide dialog and disable overlay MouseArea> and <request load values> operations to order:- Request load values
- Disable overlay
But it still bad solution: to execute long-time work while ui is blocked.
-
Hi,
I am already disabling the home button. But when the mouse press is made on top of the button, while in disabled mode, I believe that the mouse click is queued in the message queue. Once the loading of values are over, I am enabling back the HOME button after that. So the queued message(mouse click) on Home button gets fired now. Is my understanding correct ?
Is there any way to avoid this ?
-
Hi, Yes it is in same UI thread. The order I followed is
- Disable the UI for user operations
- Load the values
- Enable the UI back
Is the order correct ?
-
I am already disabling the home button. But when the mouse press is made on top of the button, while in disabled mode, I believe that the mouse click is queued in the message queue. Once the loading of values are over, I am enabling back the HOME button after that. So the queued message(mouse click) on Home button gets fired now. Is my understanding correct ?
No. Any disabled item will never generate events.
Might be some other code that is causing this. Can you post some example code that shows the problem ?
-
@AbuFahima said in How to avoid Mouse events propagation:
Is the order correct ?
Correct. Agree with @p3c0 - need some code.