Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to block background click when clicked on the item placed above ?
Forum Updated to NodeBB v4.3 + New Features

How to block background click when clicked on the item placed above ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 332 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.
  • M Offline
    M Offline
    MayankJha
    wrote on 11 May 2023, 05:16 last edited by
    #1

    Hi,
    I came across a scenario where I have a rectangle place on top of another rectangle. But when I click on top rectangle ,it is taking below rectangle's click as in below rectangle's mouse area onClicked handler is getting called.

    Can anyone please suggest me better approach to handle the mouse click separately for both rectangles ?

    S 1 Reply Last reply 11 May 2023, 05:49
    0
    • S sierdzio
      11 May 2023, 05:49

      In your top MouseArea, how do you intercept the clicks? Also using onClicked? In general, take a look at this property, it controls exactly the behaviour you are describing: https://doc.qt.io/qt-6/qml-qtquick-mousearea.html#propagateComposedEvents-prop

      M Offline
      M Offline
      MayankJha
      wrote on 11 May 2023, 07:29 last edited by
      #3

      @sierdzio If suppose I do not have any mouse area on top rectangle, then the below mouse area is getting called !

      If I have mouse area on top rectangle, then below rectangle's click is not happening, but is there any other better approach other than blocking background click using mouse area ??

      S 1 Reply Last reply 11 May 2023, 09:50
      0
      • M MayankJha
        11 May 2023, 05:16

        Hi,
        I came across a scenario where I have a rectangle place on top of another rectangle. But when I click on top rectangle ,it is taking below rectangle's click as in below rectangle's mouse area onClicked handler is getting called.

        Can anyone please suggest me better approach to handle the mouse click separately for both rectangles ?

        S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 11 May 2023, 05:49 last edited by
        #2

        In your top MouseArea, how do you intercept the clicks? Also using onClicked? In general, take a look at this property, it controls exactly the behaviour you are describing: https://doc.qt.io/qt-6/qml-qtquick-mousearea.html#propagateComposedEvents-prop

        (Z(:^

        M 1 Reply Last reply 11 May 2023, 07:29
        0
        • S sierdzio
          11 May 2023, 05:49

          In your top MouseArea, how do you intercept the clicks? Also using onClicked? In general, take a look at this property, it controls exactly the behaviour you are describing: https://doc.qt.io/qt-6/qml-qtquick-mousearea.html#propagateComposedEvents-prop

          M Offline
          M Offline
          MayankJha
          wrote on 11 May 2023, 07:29 last edited by
          #3

          @sierdzio If suppose I do not have any mouse area on top rectangle, then the below mouse area is getting called !

          If I have mouse area on top rectangle, then below rectangle's click is not happening, but is there any other better approach other than blocking background click using mouse area ??

          S 1 Reply Last reply 11 May 2023, 09:50
          0
          • M MayankJha
            11 May 2023, 07:29

            @sierdzio If suppose I do not have any mouse area on top rectangle, then the below mouse area is getting called !

            If I have mouse area on top rectangle, then below rectangle's click is not happening, but is there any other better approach other than blocking background click using mouse area ??

            S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 11 May 2023, 09:50 last edited by
            #4

            @MayankJha said in How to block background click when clicked on the item placed above ?:

            @sierdzio If suppose I do not have any mouse area on top rectangle, then the below mouse area is getting called !

            Ah then this is 100% correct behaviour. By default, all QML components are transparent to mouse clicks.

            If I have mouse area on top rectangle, then below rectangle's click is not happening, but is there any other better approach other than blocking background click using mouse area ??

            Best is to use a MouseArea, yes.

            (Z(:^

            M 1 Reply Last reply 11 May 2023, 10:29
            0
            • S sierdzio
              11 May 2023, 09:50

              @MayankJha said in How to block background click when clicked on the item placed above ?:

              @sierdzio If suppose I do not have any mouse area on top rectangle, then the below mouse area is getting called !

              Ah then this is 100% correct behaviour. By default, all QML components are transparent to mouse clicks.

              If I have mouse area on top rectangle, then below rectangle's click is not happening, but is there any other better approach other than blocking background click using mouse area ??

              Best is to use a MouseArea, yes.

              M Offline
              M Offline
              MayankJha
              wrote on 11 May 2023, 10:29 last edited by
              #5

              Thanks for the reply !! @sierdzio

              1 Reply Last reply
              0
              • M MayankJha has marked this topic as solved on 11 May 2023, 10:31

              1/5

              11 May 2023, 05:16

              • Login

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