PDA

View Full Version : QLabels autoresize to a pixmap?



hersheyzombie
23rd October 2009, 07:12
I am using Qt 4.5.2

I have a .ui to which I assigned a horizontal layout, and placed into it a qLabel.

The qLabel has scaledContents set to true.

During program execution, I set a pixmap to that qLabel. This causes the label (and the entire MainWindow) to resize to the dimensions of that pixmap. This is not my desired behavior.

I have found that in previous versions of Qt, qLabels had an autoResize property that determined whether they would expand themselves for larger content. It appears that in Qt 4.5.2, there is no longer such a property and the label will always automatically expand itself.

If anyone knows how to disable autoresizing for the qLabel or if there is another type of widget onto which I can easily display a pixmap that will not resize unless the window is resized by the user, please let me know.

Thanks.

aamer4yu
23rd October 2009, 07:16
How about trying label->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixe d); ?

hersheyzombie
24th October 2009, 00:34
Setting the sizes to "fixed" did not help: they still auto-resized to the size of the pixmap that i set to them, and even worse, then they did not stretch when i resized the window

Setting the sizes to "ignored" produced the desired effect: the windows did not resize when a larger pixmap was set, they merely scaled the contents down. And, they stretched when I stretched the window and shrank when I shrank the window.

This issue is now resolved.

Thanks!