QT 常用控件样式表

这篇博客详细介绍了如何使用CSS样式表自定义QT框架中的各种控件,包括QWidget、QLabel、QPushButton等,涵盖了背景颜色、字体、边框、高亮效果等多个方面,以实现UI界面的一致性和美观性。
摘要由CSDN通过智能技术生成


/*QWidget*/
QWidget{
 background-color: #151515;
 color: #a3a3a3;
 font-family: "Arial";
 font-size: 18px;
 font-weight: normal;}
QWidget#ConfigDlg{
 border-top: 1px solid #424242;
}
QWidget#InfoDisplay, QWidget#InfoStatic {
  background-color: #151515;
  font-family: "Arial";
  font-size: 22px;
  font-weight: 700;}

QWidget#OneStatic {
  font-family: "Arial";
  font-size: 22px;
  font-weight: 700;}

QToolTip{
 margin: 0px;
 padding:0px;
 font-family: "Arial";
 font-size: 20px;
 font-weight: normal;
}
 
QWidget#Titlebar {
 background-color: #151515;
 color: #a3a3a3;
 font-family: "Arial";
 font-size: 18px;
 font-weight: normal;}
QWidget#MessageBar {
 background-color: black;
 color: #a3a3a3;
 font-family: "Arial";
 font-size: 18px;
 font-weight: bold;} 
QWidget#pageArea {
 background-color: #222222;
 border-radius: 7px; }
QWidget#PrimaryMenu {
 background-color: #131313;}
QWidget#GaugeWnd
{
 background-image: url(":/Gauge_background.png");
}
QWidget#Statusbar {
 background-color: #151515;}
QWidget#Trackballbar {
 background-color: #151515;}
QWidget#leftPane, QWidget#rightPane, QWidget#patientViewPanel, QWidget#searchPanel, QWidget#medias {
 background-color: #222222; }
QWidget#clipboard {
 border-radius: 3px;
 border-width: 1px;
 border-style: solid;
 border-color: #424242;
 background-color: #0c0c0c; } 
 
QWidget#SoftGamma {
 border-width: 3px;
 border-style: ridge;
 border-color: grey;
 background-color: #0c0c0c; }  
 
QWidget#StatusIconBar {
 background-color: #151515;
 color: #a3a3a3;
 font-family: "Arial";
 font-size: 18px;
 font-weight: bold;
 border-radius: 3px;
 border-width: 1px;
 border-style: solid;
 border-color: #424242; }

QWidget#ParamsArea, QWidget#ModeArea, QWidget#PageNumberWnd, QWidget#ParamWnd
{
 border-radius: 3px;
 border-width: 1px;
 border-style: solid;
 border-color: #424242;
}

QWidget#ImageWidget {
 background-color: #151515;
 }

QWidget#PatientImages {
 background-color: #151515;
 }

QWidget#InfowinWidget {
 background-color: #151515;
 }
 
QWidget#TransferWidget {
 background-color: #151515;
 } 
 
QWidget#ImportViewPage {
 background-color: #151515;
 } 
 
QWidget#ExportViewPage {
 background-color: #151515;
 }
 
QWidget#PageTitle{
 border-width: 3px;
 border-style: groove;
 border-color: #2B2B2B;

/*QFrame*/
QFrame#Sep{
 background-color: #000000;
 border: none;}

QFrame#TitleSep{
 background-color: #14;
 border: none;}
 
/*QLabel*/
QLabel {
 background: transparent;
 font-size: 18px;
 color: #a3a3a3;
 font-family: "Arial";}
 
QLabel#contrast, #lcd, #brightness{
 background: transparent;
 color: #a3a3a3;
 font-family: "Arial";}
 
QLabel#ColorTemp {
 background: transparent;
 color: #a5a5a5;
 font-family: "Arial";
 font-size: 17px;
 font-weight: bold;
 border-width: 2px;
 border-style: inset;
 border-color: #151515;
 max-height: 30px} 
QLabel#Logo {
 qproperty-alignment: AlignCenter;}
QLabel#PatientData1 {
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold;
 max-width:330px;
 min-width:330px;
}
QLabel#PatientData2, QLabel#PatientData3, QLabel#Operator {
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold;}
QLabel#Location, QLabel#sysTitle{
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold;
 max-width:330px;
 min-width:330px;}
QLabel#DateTime {
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold;}
QLabel#title {
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold;}
QLabel#TermicIndex, QLabel#Probe, QLabel#Application, QLabel#MechanicalIndex {
 color: #a9a9a9;
 font-size: 18px;
 font-weight: bold; }
QLabel#ModeName, QLabel#ModeValue{
 qproperty-alignment: AlignCenter;
 color: #838383;
 font-size: 18px;
 font-weight: bold; }
 
QLabel#ParamNum, QLabel#ParamName {
 qproperty-alignment: AlignCenter;
 color: #838383;
 font-size: 18px;
 font-weight: bold; }
QLabel#ParamValue {
 qproperty-alignment: AlignCenter;
 color: #f6f6f6;
 background-color: #2f2f2f;
 border-radius: 4px;
 font-size: 18px;
 font-weight: bold; }
QLabel#ParamNum:disabled, QLabel#ParamName:disabled, QLabel#ParamValue:disabled {
 qproperty-alignment: AlignCenter;
 color: #555555;
 border-color: #303030;
 font-size: 18px;
 font-weight: bold; }
 
QLabel#ParamNameSmall {
 qproperty-alignment: AlignCenter;
 color: #838383;
 font-size: 14px;
 font-weight: bold; }
QLabel#ParamValueSmall{
 qproperty-alignment: AlignCenter;
 color: #f6f6f6;
 background-color: #2f2f2f;
 border-radius: 4px;
 font-size: 13px;
 font-weight: bold; }
QLabel#ParamNameSmall:disabled {
 qproperty-alignment: AlignCenter;
 color: #555555;
 border-color: #303030;
 font-size: 14px;
 font-weight: bold; }
QLabel#ParamValueSmall:disabled{
 qproperty-alignment: AlignCenter;
 color: #555555;
 border-color: #303030;
 font-size: 13px;
 font-weight: bold; }
 
QLabel#ParamValueON {
 qproperty-alignment: AlignCenter;
 color: #f6f6f6;
 background-color: #336baf;
 border-radius: 7px;
 font-size: 18px;
 font-weight: bold; }
QLabel#LabNum {
 qproperty-alignment: AlignCenter;
 color: #838383;
 font-size: 18px;
 font-weight: bold; }
QLabel#MeasToolText {
 image: url(":/mm_caliper.png");
 }
QLabel#LabUp {
 background-image: url(":/arrowUp_up.png");
 background-position: center center;
 background-repeat: no-repeat; }
QLabel#LabDown {
 background-image: url(":/arrowDown_up.png");
 background-position: center center;
 background-repeat: no-repeat; } 
QLabel#ModeLeft {
 background-image: url(":/arrowLeft_up.png");
 background-position: center center;
 background-repeat: no-repeat; }
QLabel#ModeRight {
 background-image: url(":/arrowRight_up.png");
 background-position: center center;
 background-repeat: no-repeat; } 
QLabel#MessageBarInfo {
 color: white;
 font-family: "Arial";
 font-size: 20px;
 font-weight: normal;}
QLabel[urgent=true]#MessageBarInfo {
 color: red;}
QLabel#TrackballBarInfo {
 color: grey;
 font-family: "Arial";
 font-size: 18px;
 font-weight: normal;}
QLabel[urgent=true]#TrackballBarInfo {
 color: white;}

QLabel#WSImages{
 border-radius: 3px;
 border-width: 1px;
 border-style: solid;
 border-color: #424242;}
 
QLabel#WSImagesSelected{
 border-radius: 3px;
 border-width: 1px;
 border-style: solid;
 border-color: #00FF00;}

QLabel#EWLine{
 border-width: 1px;
 border-color: #424242;}


/*QSplitter*/
QSplitter {
    background-color: #131313;}
QSplitter::handle {
    border:none;
    margin: 0px;
    background-color: #FFFFFF;
    width: 2px;}
QSplitter#TrackballBar {
 background-color: #151515;
 color: #a3a3a3;}

/*QDialog*/
QDialog {
  background-color: #222222; }
  QDialog#probeDialog {
    border-radius: 20px;
    border-width: 5px;
    border-style: solid;
    border-color: #424242; }
 
/*PopDialog*/
  QDialog#PopDialog {
    border-radius: 5px;
    border-width: 2px;
    border-style: solid;
    border-color: #424242; } 
 QDialog#PopDialog QLabel#Error {
  border: none;
  color: red;
  font-size: 20px;
  font-weight: bold;
  max-height: 50px;
}

/*QPushButton*/
QPushButton {
 padding: 1px 5px 1px 5px;
 font-size: 18px;
 font-weight: normal;
 border-radius: 5px;
 border-width: 1px;
 border-style: solid;
 border-color: #606060;
 color: #a3a3a3;
 height: 28px;
 background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4c4c4c, stop: 1 #333333); }
QPushButton:checked, QPushButton:pressed, QPushButton:selected {
 color: #ffffff;
 background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #3671b8, stop: 1 #285993);
 border-color: #336baf; }
QPushButton:disabled {
 color: #555555;
 background-color: #222222;
 border-color: #303030; }
QPushButton:hover {
 color: #929292;
 background-color: #1e1e1e;
 border-color: #2b2b2b; }

QPushButton#bottomButtons {
 border-bottom-left-radius: 0px;
 border-bottom-right-radius: 0px; }
QPushButton#reset {
 border-color: #606060;
 border-radius: 7px;
 border-radius: 7px;
 border-width: 1px;
 border-style: solid;
 border-color: #606060; }
QPushButton#reset:enabled {
 border-color: #222222;
 image: url(":/reset_up.png");
 image-position: left; }
QPushButton#reset:checked, QPushButton#reset:pressed, QPushButton#reset:selected {
 image: url(":/reset_dw.png");
 image-position: left; }
QPushButton#reset:disabled {
 image: url(":/reset_dis.png");
 image-position: left; }
QPushButton#Service {
 background-color: #151515;
}

QPushButton#ScanCoachEdit {
 border-width: 0px;
 font-size: 18px;
 font-weight: normal;
 color: #929292;
 height: 28px;
 background: transparent; }

 
QPushButton#ScanCoachEdit:hover {
 color: #a3a3a3;
 background-color: #1e1e1e;
 padding: 1px 5px 1px 5px;
 border-radius: 5px;
 border-width: 1px;
 border-style: solid;
 border-color: #606060; } 

 
QToolButton#UtilityButton {
    border-radius: 7px;
    border-width: 1px;
    border-style: solid;
    border-color: #606060;
    margin-right: -1px;
    padding: 10px;
    border-bottom-left-radius: 0px;
    border-bottom-right-radius: 0px;
    border-top-right-radius: 0px;
    border-top-left-radius: 0px;
 color: #a3a3a3;
 background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4c4c4c, stop: 1 #333333);  }
   QToolButton#UtilityButton:checked, QToolButton#UtilityButton:pressed, QToolButton#UtilityButton:selected {
 color: #ffffff;
 background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #3671b8, stop: 1 #285993);
 image: url(":/arrowRight_dw.png");
 image-position: right;
 /*background: #151515;*/
 border-color: #336baf; }
 QToolButton#UtilityButton:disabled {
 color: #555555;
 background-color: #222222;
 border-color: #303030; }
 QToolButton#UtilityButton:hover {
 color: #929292;
 background-color: #1e1e1e;
 border-color: #2b2b2b; }
 
/*QToolButton*/
QToolButton {
 font-size: 18px;
 color: #a3a3a3;
 background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4c4c4c, stop: 1 #333333);
 border-radius: 0px;
 border-width: 1px;
 border-style: solid;
 bord

对于Qt中的样式表,你可以使用QStyleSheet来实现界面的美化。根据引用[1]所述,QT精美样式表包含了按钮、编辑框、进度条、下拉框、表格等常用控件的美化样式,可以一套搞定QT界面。 如果你想使用Qt样式表来美化Testbrows(可能是你自定义的控件),你可以通过设置QWidget的样式表来实现。首先,你需要为Testbrows指定一个样式类名,例如"test-brows"。然后,你可以通过在样式表中使用这个类名来定义Testbrows的外观。 例如,你可以创建一个样式表字符串,如下所示: ```cpp QString styleSheet = ".test-brows { background-color: yellow; }"; ``` 这个样式表将会将Testbrows的背景颜色设置为黄色。 然后,你可以将这个样式表应用到Testbrows上,例如: ```cpp testBrows->setStyleSheet(styleSheet); ``` 这样,Testbrows就会显示出你定义的样式。 需要注意的是,如果你想美化Testbrows内部的子控件,可以使用":"选择器来指定子控件的外观。例如,为按钮指定样式,可以这样写: ```cpp QString styleSheet = ".test-brows QPushButton { color: red; }"; ``` 这个样式表将会将Testbrows内部的所有QPushButton的文字颜色设置为红色。 总结起来,你可以按照以下步骤来为Testbrows应用样式表: 1. 为Testbrows指定一个样式类名,例如"test-brows"。 2. 创建一个样式表字符串,定义Testbrows及其子控件的外观。 3. 将样式表应用到Testbrows上。 这样,你就可以通过样式表来美化Testbrows的外观了。希望这个回答对你有帮助!
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值