Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113736

Add support for customising the title bar using the Windows App SDK

    XMLWordPrintable

Details

    • Windows
    • 8dbc48248 (dev), 3a54d3109 (6.6), aa7a0cd4b (6.5)

    Description

      With recent updates to the Microsoft App SDK it is now easier to customize a window title bar for win32 apps on Windows 10 and 11.

      One feature that we would like support for in Qt is extending the content view into the titlebar which is provided by the app sdk method ExtendsContentIntoTitleBar().

      We've tried hacking this into a QML app using the following to see how Qt will react:

      #include <winrt/Windows.Foundation.h>
      #include <winrt/Windows.UI.h>
      #include <winrt/Microsoft.UI.h>
      #include <winrt/Microsoft.UI.Windowing.h>
      #include <winrt/Microsoft.UI.Interop.h>
      
      namespace winrt {
      	using namespace Windows::Foundation;
      	using namespace Microsoft::UI::Windowing;
      	using namespace Microsoft::UI;
      }
      
      ...
      
      HWND hWnd = reinterpret_cast<HWND>(winId());
      winrt::WindowId windowId = winrt::GetWindowIdFromWindow(hWnd);
      winrt::AppWindow appWindow = winrt::AppWindow::GetFromWindowId(windowId);
      auto titleBar = appWindow.TitleBar();
      if (titleBar.IsCustomizationSupported()) {
        titleBar.ExtendsContentIntoTitleBar(true);
        titleBar.ButtonBackgroundColor(winrt::ColorHelper::FromArgb(255, color().red(), color().green(), color().blue()));
      }
      

      And the attached screenshot shows the result. The main content for the qml window is not extended up into the title bar and mouse events are offset by the title bar.

      Do you have any tips for how we could possibly get this working temporarily so the QML content is correctly positioned in the window?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            timothee.keller Timothée Keller
            rupert_d Rupert Daniel
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes