首页 > 解决方案 > QLabel border visible within QGridLayout

问题描述

I'm facing a problem with UI design.

I'm using QT 4.6.2 with QTCreator 1.3.1

I have a QFrame with a background image that "draw" the grid see image below

When i add a QLabel within the layout, when i run the app i see top left border. For test, i moved out the QLabel from the Layout and it works as expected (no border at all)

Do you have any idea about that?

Thanks in advance for your kindly help

Leo

标签: qtqlabelqframe

解决方案


您可能正在使用样式表来设置 QFrame 的背景。像这样的东西:

QFrame{
    background-image: url(picture.png);
}

样式表传播到子小部件,所以我的想法是您的背景也适用于子 QLabels。

将您的样式表更改为这个(注意开头的点):

.QFrame{
    background-image: url(picture.png);
}

点选择器只会将样式表限制为 QFrame 类型为 QFrame 的子小部件,但不会将其应用于继承类,如 QLabel。请参阅文档以了解有关选择器的更多信息。


推荐阅读