Qn00b
14th October 2010, 19:31
Hello
I have a very simple problem with the setStyleSheet() function. I need to apply a simple style to a label.
If I make my form only with code (without using Qt Designer) I can't apply my style. An example:
Form::Form(QWidget *parent) : QWidget(parent) {
this->myLabel = new QLabel(this);
this->myLabel->move(0,0);
this->myLabel->resize(300, 100);
this->setStyleSheet("#myLabel{background-color: rgb(0, 0, 255);}");
}
It doesn't work, but if I make my form with Qt Designer it works:
Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::ClientFrame) {
ui->setupUi(this);
this->setStyleSheet("#label {background-color: rgb(0, 0, 255);}");
}
Someone can help me to fix the first code please??
Thanks!!
I have a very simple problem with the setStyleSheet() function. I need to apply a simple style to a label.
If I make my form only with code (without using Qt Designer) I can't apply my style. An example:
Form::Form(QWidget *parent) : QWidget(parent) {
this->myLabel = new QLabel(this);
this->myLabel->move(0,0);
this->myLabel->resize(300, 100);
this->setStyleSheet("#myLabel{background-color: rgb(0, 0, 255);}");
}
It doesn't work, but if I make my form with Qt Designer it works:
Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::ClientFrame) {
ui->setupUi(this);
this->setStyleSheet("#label {background-color: rgb(0, 0, 255);}");
}
Someone can help me to fix the first code please??
Thanks!!