Qt World Summit: Register Today!

Getting child widget to automatically resize itself to size of parent widget via Qt Creator?

  • I have a QGroupBox that contains a QTabWidget. I want the QTabWidget to fill the entire QGroupBox, so whenever the size of the QGroupBox changes, the size of QTabWidget needs to change as well.

    I'm still very new to Qt, but I am pretty well versed with wxWidgets. Now, I'm sure there's probably some sort of "resize" signal that QGroupBox might emit, which I can then hook up to a slot which would then resize the QTabWidget. I don't know enough details about Qt yet to know for sure, but I would imagine it would be something like that. However, that's doing it through code.

    I get the feeling I should able to use Qt's layouts to do the resizing for me automagically. In wxWidgets, I would stick a wxSizer (wx's version of a QLayout) inside the group box object, then stick the tab widget inside the wxSizer, adjust the wxSizer's properties accordingly and then wxWidgets would handle all the resizing for me. I'm guessing Qt's QLayout should be able to do the same thing. Furthermore, I should be able to specify all of this via Qt Creator. However, I haven't been able to figure it out.

    Can somebody please help? Thanks!

  • Indeed you should use a layout.
    You can right-click inside the group box, and you'll find the different layout types you can use there.

  • That was it, sir. Thanks!

Log in to reply