[Solved] Automatically resize QGroupBox to fit its contents.



  • Hello Qters!

    I am trying to do a very simple thing but I am a little bit confuzed.
    I have a QGroupBox and inside it I have two QLabels. One has a fixed size, while the other has the property "wordWrap" enabled and its text is changing during the runtime. When I add a big text to the second QLabel the word wrapping works fine, but I can not see all the text because it is clipped by the geometry of the QGroupBox. Is there some way to automatically resize the QGroupBox based on its contents? Thanks a lot for your time and sorry for the noob-ish question! :)

    Cheers,
    Bekos



  • Are you using a "layout":http://qt-project.org/doc/qt-4.8/layout.html in your group box?



  • You are right! I had to add a layout. Actually, I tried that in the past but it did not work using the Preview mode of the QtDesigner (dunno why). But turns out that if I just run my program it works just fine!
    Thanks a lot!

    Cheers,
    Bekos


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.