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. Create QWidget at very top of window in main layout?
Forum Update on Monday, May 27th 2025

Create QWidget at very top of window in main layout?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 379 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.
  • E Offline
    E Offline
    evankirkiles
    wrote on last edited by
    #1

    I'm trying to create a custom titlebar in a Frameless window. I want to add this title bar (which is a QWidget) to the very top of the window, as high as possible. When I add it as first in the QVBoxLayout which is my main layout, however, there is an annoying space between it and the top. I set a fixed height for my title bar widget, but I'm not sure where to go from here. How can I remove the automatic spacing between the top of the window and the first widget in the window's QVBoxLayout?

    jsulmJ 1 Reply Last reply
    0
    • E evankirkiles

      I'm trying to create a custom titlebar in a Frameless window. I want to add this title bar (which is a QWidget) to the very top of the window, as high as possible. When I add it as first in the QVBoxLayout which is my main layout, however, there is an annoying space between it and the top. I set a fixed height for my title bar widget, but I'm not sure where to go from here. How can I remove the automatic spacing between the top of the window and the first widget in the window's QVBoxLayout?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @evankirkiles I guess you need to reduce spacing: http://doc.qt.io/qt-5/qlayout.html#spacing-prop

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply
      2
      • jsulmJ jsulm

        @evankirkiles I guess you need to reduce spacing: http://doc.qt.io/qt-5/qlayout.html#spacing-prop

        E Offline
        E Offline
        evankirkiles
        wrote on last edited by
        #3

        @jsulm Found out about content margins after digging around your recommendation for a little bit. Thank you very much! :)

        1 Reply Last reply
        1

        • Login

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