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. Frameless window not working with qt 6.8

Frameless window not working with qt 6.8

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 194 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.
  • P Offline
    P Offline
    Paddle
    wrote on last edited by
    #1

    I have an application which has a custom title bar (which is still not supported by Qt btw).

    For this I have been using https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
    It implements frameless windows natively in Windows. And it was working well with Qt 5.15 :

    • Aero snaps working
    • Resizing working
    • Click and drag the title bar to move the window OK
    • Double click title bar to maximize OK
    • Shadows drawn correctly
    • Overall working perfectly.

    And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).

    On the picture below you can see the same app build with Qt5.15 on top and with Qt6.8.1 under.
    564d41bd-5e52-47fe-a7c7-79e30076be93-image.png
    This is on Windows11, so you can see the one build on 5.15 has a good native support for frameless because you can see the round corners and the correct styling/shadows.

    Here is the class if someone care to check it out : https://pastebin.com/raw/ThKuiJ26
    Note I can't put the code in because of Akismet spam detection!

    It looks like the part about SetWindowLong and DwmExtendFrameIntoClientArea is not working anymore. Does anyone know anything about it?

    Pl45m4P 1 Reply Last reply
    0
    • P Offline
      P Offline
      Paddle
      wrote on last edited by
      #2

      So it appears that SetWindowLong and/or DwmExtendFrameIntoClientArea are somehow overwriten on Qt 6.8.1 when they are done in the Ctor of the mainwindow.

      So I finally found a workaround by adding a QTimer :

          QTimer::singleShot(10, this, [this]() {
              HWND hwnd = (HWND)this->winId();
              DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
              ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
      
              const MARGINS shadow = { 1, 1, 1, 1 };
              DwmExtendFrameIntoClientArea(HWND(winId()), &shadow);
          });
      

      This way the code is not overwriten and it works. But it feels quite hacky

      I 1 Reply Last reply
      0
      • P Paddle

        I have an application which has a custom title bar (which is still not supported by Qt btw).

        For this I have been using https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
        It implements frameless windows natively in Windows. And it was working well with Qt 5.15 :

        • Aero snaps working
        • Resizing working
        • Click and drag the title bar to move the window OK
        • Double click title bar to maximize OK
        • Shadows drawn correctly
        • Overall working perfectly.

        And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).

        On the picture below you can see the same app build with Qt5.15 on top and with Qt6.8.1 under.
        564d41bd-5e52-47fe-a7c7-79e30076be93-image.png
        This is on Windows11, so you can see the one build on 5.15 has a good native support for frameless because you can see the round corners and the correct styling/shadows.

        Here is the class if someone care to check it out : https://pastebin.com/raw/ThKuiJ26
        Note I can't put the code in because of Akismet spam detection!

        It looks like the part about SetWindowLong and DwmExtendFrameIntoClientArea is not working anymore. Does anyone know anything about it?

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by
        #3

        @Paddle said in Frameless window not working with qt 6.8:

        custom title bar (which is still not supported by Qt btw)

        The title bar is decorated by the native window manager, so it's not exactly platform independent and probably not a target of a platform-independent framework like Qt.

        And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).

        Unless somebody knows better I would say that I could be a/another Windows11 style issue.

        Does it also break on 6.8 when using vista style for example?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • P Paddle

          So it appears that SetWindowLong and/or DwmExtendFrameIntoClientArea are somehow overwriten on Qt 6.8.1 when they are done in the Ctor of the mainwindow.

          So I finally found a workaround by adding a QTimer :

              QTimer::singleShot(10, this, [this]() {
                  HWND hwnd = (HWND)this->winId();
                  DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
                  ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
          
                  const MARGINS shadow = { 1, 1, 1, 1 };
                  DwmExtendFrameIntoClientArea(HWND(winId()), &shadow);
              });
          

          This way the code is not overwriten and it works. But it feels quite hacky

          I Offline
          I Offline
          IgKh
          wrote on last edited by
          #4

          @Paddle said in Frameless window not working with qt 6.8:

          But it feels quite hacky

          If the part that bothers you is the hard-coded timeout, you can put this bit of code in a showEvent handler for a more deterministic effect.

          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