QMainWindow does not receive mouse events in Linux/Wayland env
-
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?
-
Hi,
That sounds strange indeed. Can you provide a minimal example that shows this behaviour ?
-
@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). -
@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?
-
@Asperamanca
Solved by passing command line argument "-platform xcb" -