abrou
4th September 2012, 22:54
Hello,
I am trying to apply a style sheet stored in a file to my application. In particular, I would like to add padding to my QCombo-boxes, as such:
QComboBox {
padding: 3px;
color: red;
}
Note that I have added the red for testing purposes. I have several QComboBoxes, created in Qt Designer. If I apply the style sheet to the entire application (using
qApp()->setStyleSheet(styleSheet)), the text turns red but does not add the padding. This means that I am correctly reading in the text file and applying it, but I am somehow not setting the padding property properly.
Again, I tried setting the style sheet in the source code file that sets up the *.ui file.
This works:
this->setStyleSheet("QComboBox { color: red; }");
This doesn't:
this->setStyleSheet("QComboBox { padding: 3px; }");
I can successfully pad them by adding a line of code for each:
ui->ComboBox->setStyleSheet("QComboBox { padding: 3 px; }");
I can successfully change the style sheet in Qt Designer.
However, both of the solutions above must be done for each combo box, which is tedious and (I think) unnecessary. Any help would be greatly appreciated. Thanks,
AB
edit: I am using Qt Designer with Qt Creator on a 64 bit Windows 7 machine. I am using Qt version 4.7.4 (32 bit).
I am trying to apply a style sheet stored in a file to my application. In particular, I would like to add padding to my QCombo-boxes, as such:
QComboBox {
padding: 3px;
color: red;
}
Note that I have added the red for testing purposes. I have several QComboBoxes, created in Qt Designer. If I apply the style sheet to the entire application (using
qApp()->setStyleSheet(styleSheet)), the text turns red but does not add the padding. This means that I am correctly reading in the text file and applying it, but I am somehow not setting the padding property properly.
Again, I tried setting the style sheet in the source code file that sets up the *.ui file.
This works:
this->setStyleSheet("QComboBox { color: red; }");
This doesn't:
this->setStyleSheet("QComboBox { padding: 3px; }");
I can successfully pad them by adding a line of code for each:
ui->ComboBox->setStyleSheet("QComboBox { padding: 3 px; }");
I can successfully change the style sheet in Qt Designer.
However, both of the solutions above must be done for each combo box, which is tedious and (I think) unnecessary. Any help would be greatly appreciated. Thanks,
AB
edit: I am using Qt Designer with Qt Creator on a 64 bit Windows 7 machine. I am using Qt version 4.7.4 (32 bit).