Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Ability to process mouse events in a mask
Forum Updated to NodeBB v4.3 + New Features

Ability to process mouse events in a mask

Scheduled Pinned Locked Moved Unsolved Qt 6
7 Posts 2 Posters 988 Views 2 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.
  • C Offline
    C Offline
    Codester
    wrote on last edited by Codester
    #1

    Hi all.
    I am using QWidget::setMask which is a very powerful and neat feature.
    What I am trying to make work is to be able to intercept mouse events outside the mask in the same widget.
    qt issue.png
    For instance I want to be able to delegate the event to the widget if the user presses a certain keystroke inside this black hole representing the background behind this window, for example Ctrl+Shift.
    Is this feasible? Because, QMainWindow::event isn't called at all inside it.
    I have another related question, but I will ask it later, maybe the solution is related too.
    Thanks.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Codester
      wrote on last edited by Codester
      #2

      Actually my second question, is when using:

      window.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
      window.setAttribute(Qt::WA_TranslucentBackground);
      

      Mouse events are delegated to background OS when the user clicks the transparent areas, is there any ways to delegate these events to the QWidget and stop them from reaching the background when certain conditions are met?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3

        Maybe of interest ?

        Qt::WA_NoMousePropagation 73 Prohibits mouse events from being propagated to the widget's parent. This attribute is disabled by default.

        Qt::WA_TransparentForMouseEvents 51 When enabled, this attribute disables the delivery of mouse events to the widget and its children. Mouse events are delivered to other widgets as if the widget and its children were not present in the widget hierarchy; mouse clicks and other events effectively "pass through" them. This attribute is disabled by default.

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

          Thanks for your reply.
          Well I am asking this question here after a long search over similar issues/topics I found on the net, and after trying a different combinations/solutions which aren't solving my problem fully.
          AFAIK, Qt::WA_* have effect on widgets not on windows (enums in Qt::WidgetAttribute).
          The main problem is there a possible way to dismiss events and delegate them to background system widgets while still knowing about them?
          For example, using setWindowFlag(Qt::WindowTransparentForInput, true) enables clickthrough but:

          • event processing is lost completely in the QMainWindow so the QWidget::event isn't called at all (which is a problem).
          • when using setWindowFlag(Qt::WindowTransparentForInput, true) to disable clickthrough, the event system becomes somehow broken.

          My main problem summed up, I want to be able to enable/disable clickthrough correctly, while be able to query events even when clickthrough is enabled in a cross-platform way.
          If you want some real life software using this behavior, check Rainmeter (windows only widget app). So basically I already know that this is feasible with windows API, but I am looking for a crossplatform solution if available.
          Any ideas?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Codester
            wrote on last edited by
            #5

            Any suggestions at all?
            Is platform specific the last attempt?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mpergand
              wrote on last edited by mpergand
              #6

              Just a few ideas ...

              Install an EventFilter at some point (widget or window)
              Look what happens in QApplication::event() or notify()
              Put a transparent widget over the transparent region and see if you can intercept events from here.

              Good luck

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Codester
                wrote on last edited by
                #7

                Yeah, already tried these with no luck.
                Because with setWindowFlag(Qt::WindowTransparentForInput, true) or using QWidget::setMask, QApplication::event() isn't called anyway.

                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