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. Child NativeWindow blocks nativeEvent messages for a NativeWindow parent

Child NativeWindow blocks nativeEvent messages for a NativeWindow parent

Scheduled Pinned Locked Moved Solved General and Desktop
qt6nativeeventframelesswindowwinmigratewinapi
3 Posts 1 Posters 513 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.
  • B Offline
    B Offline
    bibasmall
    wrote on 22 Feb 2023, 17:08 last edited by bibasmall
    #1

    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.

    1 Reply Last reply
    0
    • B bibasmall
      22 Feb 2023, 19:06

      I found that I could installNativeEventFilter and then call CFramelessWindow::nativeEvent directly inside nativeEventFilter(), so that I would actually pass the required message into the right place, but the result looks definetely broken. What am I doing wrong?
      e3e51df1-2369-4333-971a-4e2be697db44-image.png

      B Offline
      B Offline
      bibasmall
      wrote on 26 Feb 2023, 18:43 last edited by
      #3

      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, in nativeEvent 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);
      
      1 Reply Last reply
      1
      • B Offline
        B Offline
        bibasmall
        wrote on 22 Feb 2023, 19:06 last edited by bibasmall
        #2

        I found that I could installNativeEventFilter and then call CFramelessWindow::nativeEvent directly inside nativeEventFilter(), so that I would actually pass the required message into the right place, but the result looks definetely broken. What am I doing wrong?
        e3e51df1-2369-4333-971a-4e2be697db44-image.png

        B 1 Reply Last reply 26 Feb 2023, 18:43
        0
        • B bibasmall
          22 Feb 2023, 19:06

          I found that I could installNativeEventFilter and then call CFramelessWindow::nativeEvent directly inside nativeEventFilter(), so that I would actually pass the required message into the right place, but the result looks definetely broken. What am I doing wrong?
          e3e51df1-2369-4333-971a-4e2be697db44-image.png

          B Offline
          B Offline
          bibasmall
          wrote on 26 Feb 2023, 18:43 last edited by
          #3

          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, in nativeEvent 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);
          
          1 Reply Last reply
          1
          • B bibasmall has marked this topic as solved on 26 Feb 2023, 18:43

          1/3

          22 Feb 2023, 17:08

          • Login

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