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. Child widgets climbing on top of QGroupBox title
Forum Updated to NodeBB v4.3 + New Features

Child widgets climbing on top of QGroupBox title

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 4.0k 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.
  • A Offline
    A Offline
    ajaxcrypto
    wrote on last edited by
    #1

    I have a QVBoxLayout which has two QGroupBox set to checkable. The layout inside the group box in QGridLayout which then contains some child widgets. However, the child widgets are being drawn on top of QGroupBox title. i.e.

    The QGroupBox is styles as follows:

    QWidget {
       background-color: white;
    }
    QWidget QGroupBox {
       margin: 10px;
       font-size: 11pt;
       border: 1px solid gray;
    }
    QWidget QGroupBox QWidget {
       font-size: 10pt;
       padding: 10px;
    }
    

    In the outer vertical layout, they are added one after the other.
    The output is something like this:
    0_1505324773676_qgroupbox.png

    What is the remedy for this problem?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Are you sure you insert the child into the layout ?
      Also, if you use NO stylesheets , they do it as expected?

      Just asking to find out what can be wrong.- Normally the childs will not override title.

      mrjjM 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Are you sure you insert the child into the layout ?
        Also, if you use NO stylesheets , they do it as expected?

        Just asking to find out what can be wrong.- Normally the childs will not override title.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        update
        Ok, it is your stylesheet:)
        alt text

        (no sheet)
        alt text

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ajaxcrypto
          wrote on last edited by ajaxcrypto
          #4

          But I do need to style all the child widgets and the title of the QGroupBox has to be styled as well i.e. bold, larger font size. How to correctly write the style sheet ?

          Also, in my case, if I delete the "QGroupBox" portion of the style string, I get this:

          0_1505325495832_qgb1.png

          mrjjM 1 Reply Last reply
          0
          • A ajaxcrypto

            But I do need to style all the child widgets and the title of the QGroupBox has to be styled as well i.e. bold, larger font size. How to correctly write the style sheet ?

            Also, in my case, if I delete the "QGroupBox" portion of the style string, I get this:

            0_1505325495832_qgb1.png

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @ajaxcrypto
            Ok, so you also have a insertion bug of some sort. Works fine in Designer.

            For your other issue, you can alter top margin
            alt text
            and it looks more correct
            alt text

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ajaxcrypto
              wrote on last edited by
              #6

              The group box still does not look correct, the title is not centered vertically on the frame nor the button texts are fully visible. I have a child inside on of the group boxes as a QTableWidget, whose header texts inexplicably get cutoff from both vertical directions, when I put it inside group box with style sheets.

              mrjjM 1 Reply Last reply
              0
              • A ajaxcrypto

                The group box still does not look correct, the title is not centered vertically on the frame nor the button texts are fully visible. I have a child inside on of the group boxes as a QTableWidget, whose header texts inexplicably get cutoff from both vertical directions, when I put it inside group box with style sheets.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @ajaxcrypto
                Ok, but im not sure its bug as such.

                • the title is not centered vertically on the frame
                  Nor will it be. its how it draws it
                • nor the button texts are fully visible.
                  well i didnt make box big enough.
                  alt text

                make sure to read
                http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qgroupbox

                Also for the other issue. its all a matter of size and spaces. It will not automatically adjust widget size to text
                so when you alter point size for the font, you will have to adjust default size in many cases.

                Note that Designer have a build in editor you can use to test with even if you dont use UI files in the app.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ajaxcrypto
                  wrote on last edited by
                  #8

                  A further issue from that link,
                  QGroupBox::title { font-size: 14pt; } -> This does not work, the font size is still the default size for me. I need to specify it for the whole QGroupBox and then change it for all child widgets.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ajaxcrypto
                    wrote on last edited by
                    #9

                    So, apparently changing QGroupBox QTableWidget QHeaderView::section style selector to just QTableWidget QHeaderView::section solves the header text cutoff issue for the QTableWidget (even though it is inside a QGroupBox).
                    I will be writing my own group box like widget instead, which doesn't look too daunting to recreate. Will re-post screenshots with the custom widget if possible. Should I mark this as solved?

                    mrjjM 1 Reply Last reply
                    0
                    • A ajaxcrypto

                      So, apparently changing QGroupBox QTableWidget QHeaderView::section style selector to just QTableWidget QHeaderView::section solves the header text cutoff issue for the QTableWidget (even though it is inside a QGroupBox).
                      I will be writing my own group box like widget instead, which doesn't look too daunting to recreate. Will re-post screenshots with the custom widget if possible. Should I mark this as solved?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @ajaxcrypto said in Child widgets climbing on top of QGroupBox title:

                      I will be writing my own group box like widget instead, which doesn't look too daunting to recreate. Will re-post screenshots with the custom widget if possible. Should I mark this as solved?

                      Hi
                      Well if you mostly want the frame and caption from the groupbox then
                      a custom widget is pretty forward. You can use QStyle to draw frame etc.

                      if no further attempts to fix stylesheet then yes, please do mark as solved. :)

                      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