:%2;qproperty-borderColor:%3;qproperty-focusColor:%4;}") .arg(QUIConfig::FontSize //视频回放控件 list.append(QString("VideoPlayback{qproperty-bgColor:%1;qproperty-videoBgColor:%1;" "qproperty-textColor:%2;qproperty-videoTextColor:%2;qproperty-videoDataColor :%3;qproperty-bgColorOff:%4;" "qproperty-textColorOn:%5;qproperty-textColorOff :%3;qproperty-bgColorOff:%4;" "qproperty-textColorOn:%5;qproperty-textColorOff
:%1;qproperty-colorLow:%2;qproperty-colorAlarm:%3;qproperty-colorDisable:%4;}") .arg( :%1;qproperty-textColor:%2;qproperty-ringColor:%3;qproperty-ringBgColor:%4;" "qproperty-circleColor:%5;qproperty-ringColor1:%6;qproperty-ringColor2:%7;qproperty-ringColor3:%8;}") :%1;qproperty-color2:%2;qproperty-color3:%3;qproperty-bgColor:%4;qproperty-textColor:%5;qproperty-borderColor %1;qproperty-lineColor1:%2;qproperty-lineColor2:%3;qproperty-lineColor3:%4;}") .arg(App
qApp->setStyleSheet("QGroupBox,QGroupBox*{color:red;}") 3.设置QObject属性 从Qt4.3开始,任何可设计的Q_PROPERTY都可以使用"qproperty 如: MyLabel{qproperty-pixmap:url(pixmap.png);} MyGroupBox{qproperty-titleColor:rgb(100,200,100);} QPushButton {qproperty-iconSize:20px 20px;} 盒子模型 使用样式表时,每个部件被看作拥有4个同心矩形的盒子,四个矩形的内容分别为内容(content)、填衬(padding)、边框(border
lbl = QLabel() lbl.setStyleSheet("background: teal; color: lime; font-size: 72px;" "qproperty-alignment : AlignCenter;" "qproperty-text: 'Ready.'") lbl.setSizePolicy(QSizePolicy(QSizePolicy.Ignored btn.setStyleSheet("* { background: seagreen; color: aqua; font-size: 72px; border: none }" "* { qproperty-text 控件的文本、对齐方式等属性也可以通过样式表来设置,比如qproperty-text表示文本,qproperty-alignment表示对齐方式。
ui->label->setStyleSheet("qproperty-text:hello;"); ui->label->setProperty("text", "hello"); ui->label
自定义控件为了适应整体换肤,需要用Q_PROPERTY类指定,类似于元对象,用Q_PROPERTY指定的东西,可以直接样式表控制,比如GaugePercent{qproperty-baseColor:#
ui->label->setStyleSheet("qproperty-text:hello;"); ui->label->setProperty("text", "hello"); ui->label