I use Qt.4.6 in Nokia phone.

My window, derived from QWidget, has set nontiled background:

setStyleSheet("border:none; margin: 0px; background-image: url(:/images/background.png);");

In my vertical layout there I have 3 QLabels. I want the middle one that contains image to be resized to fill all available space. If it is not stretched then the background image get duplicated on the background of the label, making an ugly effect.

How can I force it to expand? Or at least how to find out the maximum available size to set with setMinimumHeight().

有帮助吗?

解决方案

You can set the size policy of the label to expand it.

ui->yourLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

See the official documentation for more details about sizePolicy.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top