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. How can I prevent QOpenGLWidget from stealing mouse press events from MainWindow?
Forum Updated to NodeBB v4.3 + New Features

How can I prevent QOpenGLWidget from stealing mouse press events from MainWindow?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 888 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.
  • R Offline
    R Offline
    RedMarsBlueMoon
    wrote on last edited by RedMarsBlueMoon
    #1

    Hello!

    This is probably something super simple but I just can't get anything to work!
    I have a QMainWindow and I need to trigger a function as soon as the user clicks to either move or resize the window. The same function will be triggered.

    But I just can't get the QMainWindow to register my event overrides.
    The events all end up in the QOpenGLWidget sub widget.

    I'm trying things like this on the OpenGL widget,

    setMouseTracking(false);
    this->setAttribute(Qt::WA_TransparentForMouseEvents);
    this->setEnabled(false);
    

    but those didn't work.
    EDIT: Btw I'm on Linux.

    Does anyone know how to transfer mouse events back to my main window?

    Cheers
    Fred

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      I'd start by subclassing it, and overriding the appropriate virtual event handlers, passing the event back to the parent. It's derived from QWidget, so that should work.

      I light my way forward with the fires of all the bridges I've burned behind me.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RedMarsBlueMoon
        wrote on last edited by RedMarsBlueMoon
        #3

        I have sub classes of both the main window and the gl widget but I'm realising that none of them register mouse clicks on the window borders.

        I think it's the X window manager that is absorbing those events and I can't figure out to get hold of them in Qt.

        EDIT: Ideally I'd probably be best of with some callback that can happen continously while window move or window scaling is happening.
        That works for me with the QStatusBar's QSizeGrip but that effect only happens there.
        It doesn't happen if I move or resize from the side borders or the top corners.
        I'm suspecting that's because X is handling the general window transforms but the StatusBar is handled by Qt.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Might be a silly question but since it's related to resizing why not reimplement the resizeEvent method of your QMainWindow based class ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Might be a silly question but since it's related to resizing why not reimplement the resizeEvent method of your QMainWindow based class ?

            R Offline
            R Offline
            RedMarsBlueMoon
            wrote on last edited by RedMarsBlueMoon
            #5

            @SGaist
            I have done that but it only triggers after the resize has happened while I need to trigger during resize is happening. I also need during window move is happeining.
            The same with moveEvent, it only triggers after the event and not during which I need.
            Or I can do my own little loop thing if I can get mouse down|up on the window borders, which I'm also unable to figure out how to get from Qt.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you explain what you want to do during these events ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RedMarsBlueMoon
                wrote on last edited by
                #7

                I am doing some hardware video rendering on a Raspberry Pi and it does a custom draw straight over the screen.
                But I need to make it appear that it follows a Qt window that is being used by the main application. (someone else owns this project and I'm adding to it).
                So I need to take window transformation info as it happens on the fly, and modify the hardware drawing accordingly, so that it looks like it's 'attached' to the Qt window.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RedMarsBlueMoon
                  wrote on last edited by
                  #8

                  I'm having some luck just adding a X11 'XQueryPointer' to get the mouse button state and I think I can combine that with a eventFilter to allow me to do what I want.
                  Now I'm just wondering if there's a 'tick' or refresh function that I can call for a QMainWindow. But that's a different question so Iv'e made a new query for that one.

                  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