Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT QUICK - How to detect click out of mouse area?
Forum Updated to NodeBB v4.3 + New Features

QT QUICK - How to detect click out of mouse area?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.5k 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.
  • B Offline
    B Offline
    becoolnike
    wrote on last edited by
    #1

    I am a little new to QT Quick and i know there is element called MouseArea to detect key pressed or mouse activity inside a rectangular region. My question is how do you detect mouse clicks outside a mouseArea?

    Thanks in advanced

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

      Hi,

      In simple words you will need another MouseArea.
      Now consider this example:
      @
      import QtQuick 2.0

      Item {
      id: outerRect
      width: 300
      height: 300

      MouseArea {
          anchors.fill: parent
          onClicked: console.log("Outer Clicked")
      }
      
      Rectangle {
          id: innerRect
          width: 50
          height: 50
          color: "red"
      
          MouseArea {
              anchors.fill: parent
              onClicked: console.log("Inner Clicked")
          }
      }
      

      }
      @

      In above example the outerRect acts as a container for the innerRect. Now if i get you correctly you are clicking the innerRect's MouseArea for the mouse activity. If you want to handle clicks outside it you will need another MouseArea which here is defined for outerArea.
      Try running the above example.
      I'd suggest you to read "MouseArea":http://qt-project.org/doc/qt-5/qml-qtquick-mousearea.html docs.
      Hope this helps you.

      157

      1 Reply Last reply
      0
      • B Offline
        B Offline
        becoolnike
        wrote on last edited by
        #3

        Thanks for the tip

        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