Child NativeWindow blocks nativeEvent messages for a NativeWindow parent
-
Hello, everyone!
I have a top-level frameless window, and I want my application to have the Aero Snap Windows feature.
So I used the approach from this code
Qt-Nice-Frameless-Window,
which is based on using nativeEvent. It works like a charm, if I don't set Qt::WA_NativeWindow attribute for a child widget of my frameless wrapper, what I have to do. If I do, the reimplementation of nativeEvent of the top-level window doesn't get the required messages, so the widget becomes unresizable and unmovable.
If I override nativeEvent for the child native window, I see that I get the correct message when I hit the child, but I get nothing when I hit the frameless parent window.The similar problem was discussed here
What decides where a native event gets sent?
But I have to keep the Qt::WA_NativeWindow attribute for the child widget.Is there anything I can do to solve this?
Thanks in advance. Just in case, I apologize for the incorrect terminology.
-
The problem was that every child widget of the native widnow got it's own window descriptor (
HWND
), so, for example, if I hit the menubar, innativeEvent
I saw that the message had a different descriptor than the main window had.
This is what solved my problem:QApplication a(argc, argv); a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); //... CEventFilter e{ &w }; a.installNativeEventFilter(&e);
-
I found that I could
installNativeEventFilter
and then callCFramelessWindow::nativeEvent
directly insidenativeEventFilter()
, so that I would actually pass the required message into the right place, but the result looks definetely broken. What am I doing wrong?
-
The problem was that every child widget of the native widnow got it's own window descriptor (
HWND
), so, for example, if I hit the menubar, innativeEvent
I saw that the message had a different descriptor than the main window had.
This is what solved my problem:QApplication a(argc, argv); a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); //... CEventFilter e{ &w }; a.installNativeEventFilter(&e);
-