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 359 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 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 ?

    sierdzioS 1 Reply Last reply
    0
    • sierdzioS sierdzio

      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 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 ??

      sierdzioS 1 Reply Last reply
      0
      • M MayankJha

        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 ?

        sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on 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
        0
        • sierdzioS sierdzio

          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 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 ??

          sierdzioS 1 Reply Last reply
          0
          • M MayankJha

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

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on 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
            0
            • sierdzioS sierdzio

              @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 last edited by
              #5

              Thanks for the reply !! @sierdzio

              1 Reply Last reply
              0
              • M MayankJha has marked this topic as solved on

              • Login

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