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. Make window transparent to mouse events outside MouseAreas?
Qt 6.11 is out! See what's new in the release blog

Make window transparent to mouse events outside MouseAreas?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 1.2k Views
  • 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.
  • N Offline
    N Offline
    NippyFlux
    wrote on last edited by NippyFlux
    #1

    I know I might have some crazy ideas but I decide to share with you guys.

    Basically I'm making a frameless semi-transparent application with QML. There are some buttons based on MouseArea that I want to click. Besides the buttons are some other (semi-transparent) visual components but I want them to ignore any mouse events (so that I can click at other applications below them).

    Is this possible with the current QML framework (or in c++ side)?

    Things I've tried so far:

    • Qt.WA_TransparentForMouseEvents . This sadly make my window ignore all mouse events and there doesn't seem to be anyway to catch them.

    • setMask on QWindow or QQuickWidget. The mask can correctly limit mouse event capturing but it also crops all visual contents.

    Some sample code:

    import QtQuick 2.8
    
    Rectangle { // click through this
      color: Qt.rgba(1, 1, 1, 0.5)
    
      width: 640
      height: 480
    
      Rectangle { // click on this
        color: 'white'
        width: 50
        height: 50
        anchors.centerIn: parent
    
        MouseArea {
          anchors.fill: parent
          onClicked: console.log('click')
        }
      }
    }
    
    
    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