Qt World Summit: Register Today!

Auto expanding QLabel

  • Hi folks, today I have a design issue.
    I would like to build a QDockWidget containing an image in a QLabel.

    Now when undocking this QDockWidget, I would like to be able to resize it and have the QLabel take all the space.
    Is it possible without reimplementing the resizeEvent of my dock? Just with strings and any value editable through designer?
    Thanks a lot!

  • You need to apply the correct layout to the widget, and give it the sizePolicy you need.

  • Thanks for your help but could you detail your answer a bit?

  • Not without you detailing the layout that you made now ;-)

  • I currently have in my Qdock window
    V@ But obviously this is not the right way to do this.

  • No, in this way, the spacers are probably eating up your additional space (unless they have a fixed size). What do you have the spacers in there for exactly?

  • Right now it has a fixed size.
    But I would like to switch to the behavior i mentionned in my first post.
    I tried to remove all spacers, set the QLael policy to minimum expanding, and set a base size.
    -> aspect ratio is lost
    -> when docked it takes too much space.

Log in to reply