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. [solved] Groupbox title alignment vertically
Forum Updated to NodeBB v4.3 + New Features

[solved] Groupbox title alignment vertically

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 6.0k 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.
  • N Offline
    N Offline
    Ninawe
    wrote on last edited by
    #1

    Hello,
    when I make a groupbox the title is always below the border line of the groupbox. Is there any way to align the title centered vertically to the border line? It should look like this http://doc.qt.digia.com/2.3/qgrpbox-w.png, but for me the title Group Box is always much below the line.
    Thanks for any help!

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      When asking about styles it's always a good idea to state your OS, system style, Qt version and tech (QML or Widgets) and any other info you think might be useful. Styles can be wildly different with these.

      For example on my setup the text is centered.
      Here's an example how you can cutomize the look by using "stylesheets":http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qgroupbox

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Ninawe
        wrote on last edited by
        #3

        Hi, I am using Windows 7 and also Linux xUbuntu. This occurs on both OS.

        My Style looks like this:
        QGroupBox
        {
        padding: 5 5px;
        font: 14pt "Segoe UI";
        border: 1px solid rgb(194,213,221);
        border-radius: 2px;
        }

        A Groupbox looks for example like this
        QGroupBox* BarcodeBox = new QGroupBox("Barcode",BarcodeFrame);
        with
        QFrame* BarcodeFrame = new QFrame(this);

        Is there no style command to move the title vertically?

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It's right in the link I gave you. You can control the title sub-control with QGroupBox::title
          @
          QGroupBox
          {
          padding: 5px;
          font: 14pt "Segoe UI";
          border: 1px solid rgb(194,213,221);
          border-radius: 2px;
          margin-top: 8px;
          }
          QGroupBox::title {
          top: -12px;
          left: 10px;
          }
          @
          Notice that I also added a margin to the QGroupBox to provide space for the negative sub-control position.

          Btw. Is "Sagoe UI" even available on Linux?

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Ninawe
            wrote on last edited by
            #5

            Great, it works, thanks a lot!!! Didn't know the right command was top :-)

            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