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. [SOLVED] Prevent all mouse events from propagating to items below
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Prevent all mouse events from propagating to items below

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 6.1k 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.
  • MonomixM Offline
    MonomixM Offline
    Monomix
    wrote on last edited by
    #1

    Hello!

    Just getting properly into Qt Quick and QML now, the initial learning curve pain is subsiding. Alas, I have a question I thought I'd find an answer to with the power of Google, but couldn't find exactly what I was looking for.

    So: in a Qt Quick Components desktop app I have an overlay that I'm using with the rather nice "Progress Spinner":http://qt-project.org/wiki/QML_Progress_Spinner to indicate when the application is off doing stuff.

    When the app is off doing stuff, the overlay is shown over the whole window and I don't want any of the controls underneath to respond to any mouse events. At the moment, I've managed to inhibit button clicks but the elements underneath still respond to hover events (the buttons still show tooltips, the table view still highlights its header). How can I blanket prevent all mouse events from reaching the controls underneath?

    The code:
    @MouseArea {
    enabled: true
    width: parent.width
    height: parent.height
    z: parent.z
    propagateComposedEvents: false
    hoverEnabled: false
    preventStealing: true
    }@

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on last edited by p3c0
      #2

      Hello,

      the problem is you set hoverEnabled to false so your MouseArea doesn't catch this event so the event bubble down to other elements with mouse handling. I don't know if it's a bug. But here a working solution.

      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          Rectangle {
              anchors.fill: parent
              color: 'red'
              Button {
                width: 200
                height: 100
                text: "test"
                onClicked: {
                  overlay.visible = true
                }
              }
          }
          Rectangle {
            id: overlay
            z: 2
            color: "#aa000000"
            anchors.fill: parent
            MouseArea {
              anchors.fill: parent
              propagateComposedEvents: false
              hoverEnabled: true
              preventStealing: true
              onClicked: {
                overlay.visible = false
              }
            }
          }
      }
      

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • MonomixM Offline
        MonomixM Offline
        Monomix
        wrote on last edited by
        #3

        I like it when a solution is that simple. Thanks a lot!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          CreMindES
          wrote on last edited by
          #4

          Thank you, I've just run into this problem!

          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