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. QMainWindow does not receive mouse events in Linux/Wayland env

QMainWindow does not receive mouse events in Linux/Wayland env

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 427 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on 5 Oct 2023, 14:38 last edited by
    #1

    I have an old application that has run for years both on Windows and a Linux/X11 disto. I now tried to run it on RHEL 8.4, which uses Wayland.

    The application creates a QMainWindow-derived class with a simple layout and corresponding child widgets.

    I also install a global event filter through

    QApplication::instance()->installEventFilter
    

    So if an event is delivered, I should know about it. I don't filter any events though (got a breakpoint on the only line that does, and I don't hit it)
    To be doubly sure, I also override QMainWindow::mousePressEvent and log it.

    The behavior is as follows:

    • If I create a QMessageBox at startup, I can press the button just fine
    • Inside the QMainWindow, I can click my mouse all I want, and never get any events
    • I can close the QMainWindow using the "X" in the window frame
    • I also receive keyboard events while the QMainWindow has focus

    There is one interesting exception when I do receive mouse events: The layout of the main window has two children:

    • An overlay widget which just shows a PNG or a black background. This one is usually hidden, and only appears if no user input is detected for a while, or the application is in an error state
    • The actual content widget which contains a QGraphicsView

    The content widget never receives events. But if the overlay widget appears after a minute or so, I suddenly get mouse events there. In response, I hide the overlay, and no longer get events after that.

    I currently have no idea where I should start looking. Any suggestions?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Oct 2023, 18:43 last edited by
      #2

      Hi,

      That sounds strange indeed. Can you provide a minimal example that shows this behaviour ?

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

      A 1 Reply Last reply 9 Oct 2023, 07:30
      0
      • S SGaist
        5 Oct 2023, 18:43

        Hi,

        That sounds strange indeed. Can you provide a minimal example that shows this behaviour ?

        A Offline
        A Offline
        Asperamanca
        wrote on 9 Oct 2023, 07:30 last edited by
        #3

        @SGaist
        Not at this time. E.g. the Chips example works as expected. I have another (but this time QML-based application) that works as expected on the same machine.
        I'll have to narrow it down. My best guess is that the OS/Window manager simply does not forward the mouse events to my window in the first place, but that must somehow be connected to a specialty of my application that I am not aware of. But those must be strictly in the domain of Qt (window flags or attributes and that like).

        A 1 Reply Last reply 9 Oct 2023, 07:53
        0
        • A Asperamanca
          9 Oct 2023, 07:30

          @SGaist
          Not at this time. E.g. the Chips example works as expected. I have another (but this time QML-based application) that works as expected on the same machine.
          I'll have to narrow it down. My best guess is that the OS/Window manager simply does not forward the mouse events to my window in the first place, but that must somehow be connected to a specialty of my application that I am not aware of. But those must be strictly in the domain of Qt (window flags or attributes and that like).

          A Offline
          A Offline
          Asperamanca
          wrote on 9 Oct 2023, 07:53 last edited by
          #4

          @Asperamanca
          I since learned that my application responds fine when using X11, but does not seem to receive mouse events when using Wayland, and that happens both on Ubuntu and RHEL.

          Any hints what Wayland-specific traps I should look out for?

          A 1 Reply Last reply 9 Oct 2023, 08:48
          0
          • A Asperamanca
            9 Oct 2023, 07:53

            @Asperamanca
            I since learned that my application responds fine when using X11, but does not seem to receive mouse events when using Wayland, and that happens both on Ubuntu and RHEL.

            Any hints what Wayland-specific traps I should look out for?

            A Offline
            A Offline
            Asperamanca
            wrote on 9 Oct 2023, 08:48 last edited by
            #5

            @Asperamanca
            Solved by passing command line argument "-platform xcb"

            1 Reply Last reply
            0
            • A Asperamanca has marked this topic as solved on 9 Oct 2023, 08:48

            3/5

            9 Oct 2023, 07:30

            • Login

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