Qt样式表语法没有';不行?
我正在使用Qt5.0.1。我想使用样式表语法来定制小部件及其元素的特性 但是一些语法,如Qt样式表语法没有';不行?,qt,stylesheet,qtstylesheets,Qt,Stylesheet,Qtstylesheets,我正在使用Qt5.0.1。我想使用样式表语法来定制小部件及其元素的特性 但是一些语法,如QLineEdit{color:red}或 QPushButton#evilButton:pressed { background-color: rgb(224, 0, 0); border-style: inset; } 不工作,编译器会给出错误 我更改了一些语法并得到了答案。例如: QPushButton#evilButton { background-color: red;
QLineEdit{color:red}
或
QPushButton#evilButton:pressed {
background-color: rgb(224, 0, 0);
border-style: inset;
}
不工作,编译器会给出错误
我更改了一些语法并得到了答案。例如:
QPushButton#evilButton {
background-color: red;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
}
转换为:
mypushbutton->setStyleSheet("background-color:purple;"
"border-style:inset;"
"border-width: 4px;"
"border-color: green;"
"border-radius: 10px;"
"font: bold 14px;"
"min-width: 10em;"
"padding: 6px;"
);
事实上,我使用了另一个函数来实现这一点。但我无法更改第一个代码,也不知道要做什么…我应该做什么?我应该
包括什么还是其他什么是问题?我使用page来学习样式表语法。即使是我自己的Qt示例也不起作用,只会引发错误 尝试了您的示例,它在Qt5上有效
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setStyleSheet(
"QPushButton#evilButton {"
"background-color: red;"
"border-style: outset;"
"border-width: 2px;"
"border-radius: 10px;"
"border-color: beige;"
"font: bold 14px;"
"min-width: 10em;"
"padding: 6px; }"
);
}
顺便说一句,我将QS存储在文件中并从中加载样式没有人能回答我的问题?这太必要了…请帮忙忘记说。您可以为整个应用程序qApp->setStyleSheet(“”)设置qss;