Qt中QTreeWidget(QTreeView)样式设置

QTreeView {    
	background-color: rgb(35, 40, 49);
    outline: 0px;                 /*消除QTreeWidgetItem外层虚线框*/
	border: 0px solid #000000;
}
QTreeView::item {
     border: 1px solid #000000;
    border-top-color: transparent;
	border-left-color: transparent;
	height:75px;
	padding-left:28px; 
}

QTreeView::item:hover {    
	background-image: url(:/鼠标经过.png);    
}

QTreeView::item:selected {    
	border-image: url(:/点击.png);
}

QTreeView::item:selected:active{  
}

QTreeView::item:selected:!active {   
}
/*分支显示*/
QTreeView::branch {
	subcontrol-origin: padding;
    subcontrol-position: right;     
	border: 1px solid #000000;	
    border-top-color: transparent;
	border-left-color: transparent;  
	border-right-color: transparent;	
}

/*QTreeView::branch:!has-children:!has-siblings:adjoins-item {
        background: yellow;
}*/

QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {	
	image: url(:/常态.png);	
	max-width:54px;	
	min-width:54px;	
}
QTreeView::branch:has-children:!has-siblings:closed:hover,
QTreeView::branch:closed:has-children:has-siblings:hover {		
	image: url(:/鼠标经过.png);
	max-width:54px;	
	min-width:54px;	
}

QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {		
	image: url(:/常态.png);	
	min-width: 68px;
    min-height: 28px;
}
QTreeView::branch:open:has-children:!has-siblings:hover,
QTreeView::branch:open:has-children:has-siblings:hover {	
	image: url(:/鼠标经过.png);	
}

QTreeView::branch:!has-children:has-siblings:adjoins-item {	
}

QTreeView::branch:!has-children:!has-siblings:adjoins-item {
}

显示效果如下图所示:

 

  • 3
    点赞
  • 12
    收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论 3

打赏作者

晴空飞一鹤

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值