Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Overriding margins?
Qt 6.11 is out! See what's new in the release blog

Overriding margins?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 611 Views 2 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I've got an app laid out like this:

    ApplicationWindow {
        id: mainWindow
        visible: true
        ColumnLayout {
            property real marginSize: mainWindow.width * 0.025
            anchors {
                fill: parent
                leftMargin: marginSize
                rightMargin: marginSize
                bottomMargin: marginSize
            }
            Maintabbar {}
            Maincontent {}
        }
    

    I do this so that none of my components "crowd" the edges of the window. The drawback to this approach is my Maintabbar, which has a different colored background, gets the margin application as well:
    tabbar.PNG

    I can think of some cumbersome ways to get around this, but...can anyone suggest a preferred way of getting my Maintabbar background to spread the entire window?

    Thanks...

    1 Reply Last reply
    0
    • mzimmersM mzimmers

      Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #4

      @mzimmers said in Overriding margins?:

      Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

      ApplicationWindow {
          id: mainWindow
          visible: true
          menuBar: Maintabbar {}
          
          Maincontent {
              anchors {
                  fill: parent
                  margins: mainWindow.width * 0.025
              }
          }
      }
      

      https://doc.qt.io/qt-6/qml-qtquick-controls2-applicationwindow.html#details
      ApplicationWindow sections

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      mzimmersM 1 Reply Last reply
      1
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #2

        can not you simply take menubar out of the layout?

        1 Reply Last reply
        0
        • mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #3

          Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

          JKSHJ 1 Reply Last reply
          0
          • mzimmersM mzimmers

            Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by JKSH
            #4

            @mzimmers said in Overriding margins?:

            Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

            ApplicationWindow {
                id: mainWindow
                visible: true
                menuBar: Maintabbar {}
                
                Maincontent {
                    anchors {
                        fill: parent
                        margins: mainWindow.width * 0.025
                    }
                }
            }
            

            https://doc.qt.io/qt-6/qml-qtquick-controls2-applicationwindow.html#details
            ApplicationWindow sections

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            mzimmersM 1 Reply Last reply
            1
            • JKSHJ JKSH

              @mzimmers said in Overriding margins?:

              Well, I have to use something to prevent Maincontent from overwriting Maintabbar.

              ApplicationWindow {
                  id: mainWindow
                  visible: true
                  menuBar: Maintabbar {}
                  
                  Maincontent {
                      anchors {
                          fill: parent
                          margins: mainWindow.width * 0.025
                      }
                  }
              }
              

              https://doc.qt.io/qt-6/qml-qtquick-controls2-applicationwindow.html#details
              ApplicationWindow sections

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #5

              @JKSH yep, that did it. Thanks.

              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