QT 自定义样式表

QPushBitton

QPushButton{
min-width:75px;
max-width:75px;
min-height:20px;
border:1px solid black;  // 边框
border-radius:5px;  //圆角
}
QPushButton:pressed{
background-color: #111111;
border-color: #333333;
color: yellow;
}

 

样式:

 

圆形QLabel

QLabel{
    min-width:60px;
    max-width:60px;
    min-height:60px;
    max-height:60px;
    border-radius:30px;  //圆角
    border:1px solid black;  //边框线
}

样式:

 

也可以使用setStyleSheet()函数来设计样式:

例如:

  

ui->time_label->setStyleSheet("QLabel{font: 15pt 宋体;color:rgb(255, 255, 255);background-color: #222648;"
                                  "min-width:180px;max-width:180px;min-height:180px;max-height:180px;border:1px solid white;border-radius:90px}");

 

其它控件样式表:

指定QLabel中的label_1

QLabel#label_3{
    color:rgb(0,193,231);
}
QLabel#label_2{
    color:white;
}
QLabel#label_1{
    color:white;
}

QTableWidget

QTableWidget{
    outline:0px;
    font: 14px "Microsoft YaHei";
      border:1px solid #1B5FA1;
      background-color:rgba(255, 255, 255, 0%);
      gridline-color:#1B5FA1;
      color: #FFFFFF;
      border-top:0px solid #EEF1F7;
    alternate-background-color:rgba(6, 69, 127, 0.29);
}
QHeaderView::section{
      text-align:center;
    color: #AFE4FF;
    background-color: rgba(5, 81, 139, 0.63);
    font: 16px "Microsoft YaHei";
    padding:3px;
    margin:0px;
    border:0px solid #242424;
    border-top-width:0;
    border-right-width:0;
}
QTableWidget::item:selected{
    background:rgba(0,8,50,0);
}

QLineEdit

QLineEdit{
  border:1px solid rgb(28,74,121);
  background-color: rgba(255, 255, 255, 0%);  //添加背景色,第四个参数为透明度范围(0,1)
  color:white;
}
QRadioButton
QRadioButton{
    color:#19e085;
    font:14px 'Microsoft YaHei';
}
QRadioButton::indicator{        //QRadioButton的方框
    background-color:#19e085;
    width:10px;
    height:10px;
    border-radius:5px;
}

 

posted on 2020-09-23 15:55  缘随风烬  阅读(893)  评论(0编辑  收藏  举报