常用的控件样式风格设置(qss)——QtWidgets

本文介绍了如何使用QSS进行QtWidgets界面的样式风格设置,包括QPushButton、QDateTimeEdit、QGroupBox等常见控件的示例,并提供了字体、图标资源的推荐,帮助开发者快速美化界面。
摘要由CSDN通过智能技术生成

前言

QtWidgets写界面,经常需要用qss来写样式风格。qss不难懂,也不难学,而且也不用特意去学,只需要复制粘贴(* ̄︶ ̄)。

所以我在此整理一下,为了下次能够更快的设置好风格,我真是个热爱工作的好同志。

常用控件样式风格设置

各类按钮(QPushButton为例)

QPushButton#searchButton{
  color:#ffffff;
  background: #0275FF;
  border-radius: 3px;
}
QPushButton#searchButton:hover,QPushButton#searchButton:pressed{
  background: rgb(70,98,217);
}

QDateTimeEdit

QDateTimeEdit{
   border:none;
   border-radius:10px;
   background-color:rgba(8, 55, 132, 1);
   color:white;
   font-size:18px;
   padding:10px 40px 10px 40px;
}
QDateTimeEdit::up-arrow{
	image: url(:/res/dlg/up-button.png);
 }
 QDateTimeEdit::down-arrow {
	image: url(:/res/dlg/dropArrow.png);
 }

QGroupBox

QGroupBox{
  background:rgba(23, 70, 141, 200);
  border:1px solid black;
  border-radius:10px;
  margin-top:20px;
}
QGroupBox::title {
  color:#05edfe;
  subcontrol-origin: margin;
  subcontrol-position: top left;
  padding-top: 5;
  padding-left: 20; 
}

 QComboBox下拉框

    QList<QComboBox*> comboxList=this->findChildren<QComboBox*>();
    foreach (QComboBox* box, comboxList) {
        box->setView(new QListView());

    }
QComboBox:!enabled{
  border: 1px solid #CCCCCC;
  color:#B3B3B3;
}
QComboBox:enabled{ 
  border: 1px solid #999999;
  border-radius: 3px;
  padding: 1px 5px 1px 10px;
  color:#666666;
  font-size:9pt;
}
QComboBox::drop-down {
  subcontrol-origin: padding;
  subcontrol-position: top right;
  padding-right:10px;
  width:20px; 
  border:none;
}
QComboBox::down-arrow {
	image: url(:/res/down.png);
}
QComboBox QAbstractItemView{
  background:rgba(255,255,255,1);
  border:1px solid rgba(228,228,228,1);
  border-radius:0px 0px 5px 5px;
  font-size:14px;
  outline: 0px;  
}

QComboBox QAbstractItemView::item{
	height:36px;
	color:#666666;
	padding-left:9px;
	background-color:#FFFFFF;
}
QComboBox QAbstractItemView::item:hover{ /*悬浮*/
  background-color:#409CE1;
  color:#ffffff;
}
QComboBox QAbstractItemView::item:selected{/*选中*/
  background-
  • 7
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值