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. Modern titlebars in Qt widget based desktop applications
Forum Updated to NodeBB v4.3 + New Features

Modern titlebars in Qt widget based desktop applications

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 475 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    schrute
    wrote on 21 Dec 2024, 08:15 last edited by
    #1

    Is it possible to have modern looking titlebars, that allow the app to place widgets inside them, in a Qt widget based desktop application. For eg - In the following apps (macOS and win), the content extends into the title bar
    Screenshot 2024-12-21 at 1.02.18 PM.png

    image (1).png

    I would like to avoid creating a frameless window and writing my own custom titlebar.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Dec 2024, 20:50 last edited by
      #2

      Hi,

      Since these are provided by the OS, you will need to add platform specific code to modify the title bar.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        schrute
        wrote on 22 Dec 2024, 12:19 last edited by schrute
        #3

        @SGaist Do you have any suggestions on how to approach the problem?

        The easiest solution would be to make the QMainWindow frameless and draw the titlebar myself. However, that is not ideal since it removes the chrome as well and leads to a poor user experience. For eg - Window borders, shadows are lost, traffic lights (and equiavalent controls on win) are lost, resize/move have to be handled manually and operations provided by the window manager (snap to side etc) also stop working. It seems Qt is aware of these issues as per this blog post https://docs.microsoft.com/en-us/windows/win32/dwm/customframe#extending-the-client-frame

        I would like to keep as much native look and feel and functionality of the titlebars/window manager as possible.

        One approach would be to create a native window myself using the OS APIs and make the content extend into the title bar. Then somehow embed a QWidget in the root view of the window. However, I am not sure if this would be possible and/or a robust solution.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Dec 2024, 20:52 last edited by
          #4

          You can get a native window from Qt.

          Based on the link you posted, there's an native event loop handler that you would need to implement in order to manage the native events of interest.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            schrute
            wrote on 23 Dec 2024, 12:40 last edited by
            #5

            Sorry, I shared the incorrect blog post, I wanted to share this instead https://www.qt.io/blog/custom-window-decorations, though it doesn't solve much.

            1 Reply Last reply
            0

            1/5

            21 Dec 2024, 08:15

            • Login

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