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. Make a widget transparent for mouse and keyboard events (propagate to the Window System Manager)
Forum Updated to NodeBB v4.3 + New Features

Make a widget transparent for mouse and keyboard events (propagate to the Window System Manager)

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 27.8k 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.
  • K Offline
    K Offline
    kibsoft
    wrote on last edited by
    #1

    Hi everyone
    I have a transparent fullscreen widget and I want to propagate mouse and keyboard event to the system. i.e. use web-browser, file manager and etc.
    Is there a way to do that?

    1 Reply Last reply
    0
    • napajejenunedk0N Offline
      napajejenunedk0N Offline
      napajejenunedk0
      wrote on last edited by
      #2

      Probably the Qt::WA_TransparentForMouseEvents "widget attribute":http://qt-project.org/doc/qt-4.8/qt.html#WidgetAttribute-enum should do the work:
      @
      QWidget w;
      w.setAttribute( Qt::WA_TransparentForMouseEvents );
      @

      bq. Qt::WA_TransparentForMouseEvents:
      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
      1
      • K Offline
        K Offline
        kibsoft
        wrote on last edited by
        #3

        Thanks for the reply, but it works only within the bounds of the application. I think I should use Native API calls, i.e. simulate events for underlying windows, but it is not simple.
        If yo have another idea, please write here :)

        1 Reply Last reply
        0
        • napajejenunedk0N Offline
          napajejenunedk0N Offline
          napajejenunedk0
          wrote on last edited by
          #4

          Could you explain the problem in greater detail...

          You have your application running. The user gives some input, you detect this input in your application and want to explicitly pass it to another application or to the Window System Manager?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kibsoft
            wrote on last edited by
            #5

            Yep. There is my app on top of the window stack (transparent) where I can paint on. But when none of any instruments for painting is selected then I want to pass any mouse and keyboard events to other apps. I mean, all the lines and other painted elements stay on screen, but user can interact with system as usually.
            I need it in order to do video lessons capturing video from screen.

            1 Reply Last reply
            0
            • napajejenunedk0N Offline
              napajejenunedk0N Offline
              napajejenunedk0
              wrote on last edited by
              #6

              So, first off, you have created an application that when run shows some windows - palettes with instruments for painting. You say that your application does not occupy the whole screen but just some regions that provide the aforementioned tools. You want to draw on screen if a given instrument of your application is in use - for instance select or paint a region on the screen below which another application's window is positioned. You want the other applications to receive the mouse and keyboard events when no tool is selected.

              So your problem should be how not to pass events to the other applications when the user clicks outside of all painting tools palettes ' windows during the time a tool is active. Isn't it this the actual question?

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                zeFree
                wrote on last edited by
                #7

                Hello Guys,

                Forget everything else and see "this":http://stackoverflow.com/a/4930925/1082289.

                Although it is not cross-platform (Windows specific) but it works like charm! : )
                I hope you like it.

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nilsge
                  wrote on last edited by
                  #8

                  Was this ever solved for Linux?

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Donald Duck
                    wrote on last edited by Donald Duck
                    #9

                    This worked for me:

                    myWidget.setWindowFlags(Qt::WindowTransparentForInput);
                    
                    1 Reply Last reply
                    3

                    • Login

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