Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to avoid Mouse events propagation
Forum Updated to NodeBB v4.3 + New Features

How to avoid Mouse events propagation

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AbuFahima
    wrote on last edited by
    #1

    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.

    R 1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @AbuFahima

      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 ?

      157

      A 1 Reply Last reply
      1
      • A AbuFahima

        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.

        R Offline
        R Offline
        Roumed
        wrote on last edited by
        #3

        @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:

        1. Request load values
        2. Disable overlay

        But it still bad solution: to execute long-time work while ui is blocked.

        A 1 Reply Last reply
        0
        • p3c0P p3c0

          @AbuFahima

          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 ?

          A Offline
          A Offline
          AbuFahima
          wrote on last edited by
          #4

          @p3c0

          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 ?

          1 Reply Last reply
          0
          • R Roumed

            @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:

            1. Request load values
            2. Disable overlay

            But it still bad solution: to execute long-time work while ui is blocked.

            A Offline
            A Offline
            AbuFahima
            wrote on last edited by
            #5

            @Roumed

            Hi, Yes it is in same UI thread. The order I followed is

            1. Disable the UI for user operations
            2. Load the values
            3. Enable the UI back

            Is the order correct ?

            R 1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @AbuFahima

              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 ?

              157

              1 Reply Last reply
              0
              • A AbuFahima

                @Roumed

                Hi, Yes it is in same UI thread. The order I followed is

                1. Disable the UI for user operations
                2. Load the values
                3. Enable the UI back

                Is the order correct ?

                R Offline
                R Offline
                Roumed
                wrote on last edited by
                #7

                @AbuFahima said in How to avoid Mouse events propagation:

                Is the order correct ?

                Correct. Agree with @p3c0 - need some code.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved