Qt-jambi-interest Archive, June 2007
StyleSheet "padding" property bug?
Message 1 in thread
Hello and good morning.
We use the next StyleSheet :
QFrame#centralFrame > QLabel#llogoLabel {
background-image: url(classpath:/path/icons/logo.png);
/* Image logo 60px x 170 px */
background-repeat: no-repeat;
padding: 60px 170px 0px 0px;
}
It's common for all the widgets, they have a QFrame with : QLabel +
HSpacer + QButton in a QHBoxLayout at the top.
In the main window :
class MainWindow extends QMainWindow {
...
// MainWindow's Constructor
QFile qss = new QFile ("classpath:qss/stylesheet.css");
qss.open(OpenModeFlag.ReadOnly);
String stylesheet = qss.readAll().toString();
qss.close();
this.setStyleSheet(stylesheet);
// Set the StyleSheet --> OK
...
// methods to change the central Widget
public void one() {
System.out.println(" One ");
this.setCentralWidget(new OneWidget(this));
}
public void other() {
System.out.println(" Other ");
this.setCentralWidget(new OtherWidget(this));
}
With this code, the "padding" property is ignored and the "logoLabel"
doesn't mantain the correct size.
The solution that I find :
public void one() {
System.out.println(" ONE ");
this.setCentralWidget(new OneWidget(this));
// RE-SET the custom styleSheet
this.setStyleSheet(this.styleSheet());
}
public void Other() {
System.out.println(" Other ");
this.setCentralWidget(new OtherWidget(this));
// RE-SET the custom styleSheet
this.setStyleSheet(this.styleSheet());
}
Message 2 in thread
Fernando Rosado Altamirano wrote:
> Hello and good morning.
>
> We use the next StyleSheet :
>
> QFrame#centralFrame > QLabel#llogoLabel {
> background-image: url(classpath:/path/icons/logo.png);
> /* Image logo 60px x 170 px */
> background-repeat: no-repeat;
> padding: 60px 170px 0px 0px;
> }
>
> It's common for all the widgets, they have a QFrame with : QLabel +
> HSpacer + QButton in a QHBoxLayout at the top.
...
> With this code, the "padding" property is ignored and the "logoLabel"
> doesn't mantain the correct size.
...
Hi Fernando,
There is a bug in the stylesheet handling that makes it ignore the
padding property for the QLabel in this case, I've notified the Qt team
about this bug.
As a workaround for now, you can set the QLabel stylesheet directly on
the label as you already suggested.
Thanks for reporting!
-
Gunnar