这种样式的美化, 能气死个人,css 一个单词搞定,非要 在qss中。多少个单词不知道了。
m_tree_widget->setStyleSheet("QTreeView{background:transparent; selection-background-color:transparent;}""QTreeView::branch{border-left:1px solid #0D85FF;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:has-siblings:!adjoins-item {border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:has-siblings:adjoins-item {border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:!has-children:!has-siblings:adjoins-item {border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:closed:has-children:has-siblings{border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:has-children:!has-siblings:closed{border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:open:has-children:has-siblings {border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}""QTreeView::branch:open:has-children:!has-siblings {border-left:none;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF; }""QTreeView::item::first{border-right:1px solid #0D85FF;color:#01A7FD;}""QTreeView::item::last{border-right:1px solid #0D85FF; color:#FFFFF;}""QTreeView::item{height:40px;border-top:1px solid #0D85FF; border-bottom:1px solid #0D85FF;}""QTreeView::item:selected{border-top:1px solid #0D85FF; border-bottom:1px solid #0D85FF;}""QTreeView::item::last:selected{border-right:1px solid #0D85FF;}""QTreeView::branch:selected{border-left:1px solid #0D85FF;border-top:1px solid #0D85FF;border-bottom:1px solid #0D85FF;}");
最终效果
参考
QTreeWidget样式qss_qtreewidget qss-CSDN博客