一些Qt样式

这篇文章展示了如何使用Qt样式表(QSS)对GUI元素如QPushButton、QScrollBar、QTableWidget和QTabBar进行自定义,包括颜色、背景、边框和状态变化时的样式。这些样式设置用于增强用户界面的视觉效果和交互体验。
摘要由CSDN通过智能技术生成

QPushButton按钮

QPushButton{
	color: rgb(255, 255, 255);
	background-color: rgba(56, 71, 115, 150);
	border-radius:10px;
	padding:5px;
}

QPushButton:hover{
	background-color: rgb(56, 71, 115);
}

QPushButton:pressed{
	background-color: #131827;
}

QPushButton:checked{
	background-color: #131827;
}

QPushButton:disabled{
	color:rgb(161, 161, 161);
	background-color: rgba(218, 218, 218, 100);
}

QScrollBar 滚动条

/* 垂直滚动条 */
QScrollBar::vertical{
	background:transparent;
	width:8px;
	border:none;
}

QScrollBar::add-line:vertical{
	background:none;
	border:none;
}

QScrollBar::sub-line:vertical{
	background:none;
	border:none;
}

QScrollBar::add-page:vertical{
	background:transparent;
	border:none;
}

QScrollBar::sub-page:vertical{
	background:transparent;
	border:none;
}

QScrollBar::handle:vertical{
	background: rgba(111, 134, 147, 100);
	border-radius:4px;
}

QScrollBar::handle:vertical:hover{
	background: rgba(111, 134, 147, 180);
}

QScrollBar::handle:vertical:pressed{
	background: rgba(111, 134, 147, 255);
}

/* 水平滚动条 */
QScrollBar::horizontal{
	background:transparent;
	height:8px;
	border:none;
}

QScrollBar::add-line:horizontal{
	background:none;
	border:none;
}

QScrollBar::sub-line:horizontal{
	background:none;
	border:none;
}

QScrollBar::add-page:horizontal{
	background:transparent;
	border:none;
}

QScrollBar::sub-page:horizontal{
	background:transparent;
	border:none;
}

QScrollBar::handle:horizontal{
	background: rgba(111, 134, 147, 100);
	border-radius:4px;
}

QScrollBar::handle:horizontal:hover{
	background: rgba(111, 134, 147, 180);
}

QScrollBar::handle:horizontal:pressed{
	background: rgba(111, 134, 147, 255);
}

QTableWidget表格

/*表格的一种美化方式*/
QHeaderView{
    /*font-size:18px;*/
    background:transparent;
}
QTableCornerButton::section{
	background:rgb(126, 145, 176);
}

QHeaderView::section{
    color:#FFFFFF;
    background:rgb(126, 145, 176);
    border:none;
	border-left: 1px solid #333333;
    text-align:center;
    padding-left:2px;
	padding-right:2px;
}

QTableWidget{
    background:#FFFFFF;
    border:none;
	outline:none;
    /*font-size:18px;*/
    color:#666666;
}

QTableWidget::item{
	border-left:1px solid #EEF1F7;
    border-bottom:1px solid #EEF1F7;
}

QTableWidget::item::selected{
    color:rgb(0, 0, 0);
    background:#EFF4FF;
}


QTabWidget QTabBar

QTabBar::tab {
    color: #666666;
	background-color: rgb(218, 218, 218);
	border: 1px solid rgb(107, 136, 179);
	border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
	padding: 4px;
}

QTabBar::tab:selected {
    color: #333333; 
    font-weight:bold
}

QTabBar::tab:hover {
    color: #666666;
	font-weight:bold;
}
 
QTabBar::tab:!selected {
    margin-top: 2px; /* make non-selected tabs look smaller */
}
 
 /* make use of negative margins for overlapping tabs */
QTabBar::tab:selected {
     /* expand/overlap to the left and right by 4px */
    margin-left: -4px;
    margin-right: -4px;
}
 
QTabBar::tab:first:selected {
    margin-left: 0; /* the first selected tab has nothing to overlap with on the left */
}
 
QTabBar::tab:last:selected {
    margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
}

Menu右键菜单

QMenu{
    /*background-color:rgba(156, 178, 206, 150);*/
    border: 1px solid #CCCCCC;
    border-radius:10px;
    margin: 0px;
}

QMenu::item:text{
    padding:3px 25px 3px 25px;
}

/*QMenu::item#save_action{
    border-top-left-radius:10px;
    border-top-right-radius:10px;
    background:rgba(156, 178, 206, 100);
}

QMenu::item#del_action{
    border-bottom-left-radius:10px;
    border-bottom-right-radius:10px;
    background:rgba(156, 178, 206, 255);
}*/

QMenu::item:selected:enabled{
    border-radius:10px;
    background-color:rgba(156, 178, 206, 150);
}

QMenu::item:selected:!enabled{
    background:transparent;
}

QMenu::separator{
    height:0px;
    background:rgb(56, 71, 115);
    margin:0px;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值