Qt--样式表

  1. 文件名编辑为 style.qss

内容如:

QTextEdit{    
  background: #033441;
  color:#64eefa;
  border:1px solid #64eefa;
}
QLineEdit{    
  background: #033441;
  color:#64eefa;
  border:1px solid #64eefa;
}
QComboBox{    
  background: #033441;
  color:#64eefa;
  border:1px solid #64eefa;
}
QTreeWidget{    
  background: #033441;
  color:#64eefa;
  border:1px solid #64eefa;
}

QGroupBox{    
  color:#64eefa;
  border:0.5px solid #64eefa;
}

QLineEdit#lineEdit_client_id,
QLineEdit#lineEdit_request_id,
QLineEdit#lineEdit_cjbh{    
  background: #535353;
  color:#64eefa;
}

QLabel#label_jg,
QLabel#label_ret,
QLabel#label{  
   color:#64eefa;
}

QLabel#label_ret{  
   font-size:18px;
}


QDialog[objectName = "faceCheckDlg"]{
	border-image: url(./imghx/check/body.png); 
}


QWidget[objectName = "centralWidget"]{
	border-image: url(./imghx/body.png); 
}


QPushButton[objectName ="pushButton_cp"]{ 
    border-image: url(./imghx/cp1.png);  
}
QPushButton:disabled[objectName ="pushButton_cp"]{ 
    border-image: url(./imghx/cp3.png);  
}
QPushButton:pressed[objectName ="pushButton_cp"]{ 
    border-image: url(./imghx/cp2.png);  
}
  1. 在main.cpp加载文件
QFile file("./images/style.qss");
file.open(QFile::ReadOnly);
a.setStyleSheet(file.readAll());
file.close();

3.在代码中临时添加

ui.centralWidget->setStyleSheet("QWidget[objectName = 'centralWidget']{ border-image: url(./img/body.png); }");
ui.label_18->setStyleSheet("QLabel[objectName = 'label_18']{ border-image: url(./img/low.png); }");
ui.pushButton_reg->setStyleSheet("QPushButton[objectName = 'pushButton_reg']{ border-image: url(./img/reg2.png); }");

参考
Qt-QSS
https://blog.csdn.net/lmhuanying1012/category_7039268.html

QT之常用样式(样式代码可直接使用)
https://blog.csdn.net/panchang199266/article/details/104207844?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.channel_param

QSS样式表汇总
https://blog.csdn.net/LearnLHC/article/details/108669612?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-4.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-4.nonecase

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值