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. QGroupBox does not scale with contents and disappears when resizing the program
Forum Updated to NodeBB v4.3 + New Features

QGroupBox does not scale with contents and disappears when resizing the program

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.1k 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
    szumial
    wrote on last edited by
    #1

    Hi! I am using a mixed approach in developement qith Qt: I usually place the widgets using QtDesigner, order them in layouts and add a grid layout to the application / widget and I use CPP to achieve some configuration programatically.

    I am having a problem with the QGroupBox with this approach. I created three group boxes and put layouts with widgets into them using QtDesigner. The enabled/disabled and radiobutton properties work great. However, I cant't figure out how to set the size of the group boxes to fit the contents of the layouts I put inside them. What happens is, if I don't stretch the objetcts myself, when the program launches, the contents are cut, not all of what I need is visible.

    What I want to achieve? After putting all of the widgets on the page to a grid layout, I want to resize the page to minimum size, which should be sufficient to contain all of the contents without cutting any text or buttons.

    Here is my MainWindow in QtDesigner:

    c97a1088-df5c-4ae9-937e-ebd39559b0b6-image.png

    And when I do the grid layout and try resizing:
    3bd43346-3f92-414c-b153-6f21aad476bc-image.png

    jsulmJ 1 Reply Last reply
    0
    • S szumial

      Hi! I am using a mixed approach in developement qith Qt: I usually place the widgets using QtDesigner, order them in layouts and add a grid layout to the application / widget and I use CPP to achieve some configuration programatically.

      I am having a problem with the QGroupBox with this approach. I created three group boxes and put layouts with widgets into them using QtDesigner. The enabled/disabled and radiobutton properties work great. However, I cant't figure out how to set the size of the group boxes to fit the contents of the layouts I put inside them. What happens is, if I don't stretch the objetcts myself, when the program launches, the contents are cut, not all of what I need is visible.

      What I want to achieve? After putting all of the widgets on the page to a grid layout, I want to resize the page to minimum size, which should be sufficient to contain all of the contents without cutting any text or buttons.

      Here is my MainWindow in QtDesigner:

      c97a1088-df5c-4ae9-937e-ebd39559b0b6-image.png

      And when I do the grid layout and try resizing:
      3bd43346-3f92-414c-b153-6f21aad476bc-image.png

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

      @szumial Apply a top-level layout to your widget...

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

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

        Hi
        The red layouts are meant to be used inside other layouts.
        They wont snap to the widget and sort of float around.

        So they are not the main way to apply a layout to a widget.
        It is to right-click the QWidget and use the layout menu.

        And yes, it is counterintuitive when all the other widgets are dragged from the right. :)

        S 1 Reply Last reply
        2
        • mrjjM mrjj

          Hi
          The red layouts are meant to be used inside other layouts.
          They wont snap to the widget and sort of float around.

          So they are not the main way to apply a layout to a widget.
          It is to right-click the QWidget and use the layout menu.

          And yes, it is counterintuitive when all the other widgets are dragged from the right. :)

          S Offline
          S Offline
          szumial
          wrote on last edited by
          #4

          @mrjj Thanks for the hint! I assumed that I need to create a layout, then drag and drop it inside the QGroupBox. Right-clicking on the group box when it already contains the desired objects and selecting a layout for it works just as expected!

          mrjjM 1 Reply Last reply
          0
          • S szumial

            @mrjj Thanks for the hint! I assumed that I need to create a layout, then drag and drop it inside the QGroupBox. Right-clicking on the group box when it already contains the desired objects and selecting a layout for it works just as expected!

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

            @szumial
            Hi
            Yep. Those red layouts are very tempting to use :)

            However, its completely the other way,
            you place some widgets on another widget, then
            apply layout :)
            Ps. If you see the layout menu being disabled,
            It's because you must place at least one widget.

            Also, since you are a Mixer like me
            be aware that the Designer sort of flattens the "tree" a bit with layout

            so a layout is available via

            ui->layoutname->

            and not like one might think

            ui->widgetname->layoutname

            Even one did right-click that widget and assign a layout.

            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