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 does QT Handle overlapping mouse areas?
Forum Updated to NodeBB v4.3 + New Features

How does QT Handle overlapping mouse areas?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 788 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
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I am creating a plotting component, which has a MouseArea over the whole window for zooming and dragging. On top of this, I want to be able to set marks like this:

            Rectangle{
                id: recMark
                border.width: 0
                width: 1
                height: parent.height
                y: 0
                z: 5
                color: "red"
                opacity: 0.3
                visible: true
                MouseArea {
                    anchors.fill: parent
                    drag.target: recMark
                    drag.axis: Drag.XAxis
    
                }
            }
    

    Which MouseArea will be active if I click on this Rectangle? And is it possible to control which MouseArea is active?

    sierdzioS 1 Reply Last reply
    0
    • M maxwell31

      Hi,

      I am creating a plotting component, which has a MouseArea over the whole window for zooming and dragging. On top of this, I want to be able to set marks like this:

              Rectangle{
                  id: recMark
                  border.width: 0
                  width: 1
                  height: parent.height
                  y: 0
                  z: 5
                  color: "red"
                  opacity: 0.3
                  visible: true
                  MouseArea {
                      anchors.fill: parent
                      drag.target: recMark
                      drag.axis: Drag.XAxis
      
                  }
              }
      

      Which MouseArea will be active if I click on this Rectangle? And is it possible to control which MouseArea is active?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @maxwell31 said in How does QT Handle overlapping mouse areas?:

      Which MouseArea will be active if I click on this Rectangle? And is it possible to control which MouseArea is active?

      The topmost one (determined by z value) will be "active" - it will catch mouse events.

      You can pass them on if you want your bottom one to get some events: in respective event slot set mouse.accepted = false and the event will be propagated further.

      All this is described in detail here: link.

      (Z(:^

      1 Reply Last reply
      2
      • JoeCFDJ JoeCFD referenced this topic on

      • Login

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