标题:请问大侠们,怎么通过stylesheet在代码中设置qtreewidget的滚动条啊
作者:kevin_wmy
日期:2009-09-20 16:33
内容:
怎么通过stylesheet在代码中设置qtreewidget的滚动条的滑动块和2端的箭头啊,我下面这样做没有效果啊(好像只verticalScrollBar()->setStyleSheet("background-color 时候能有作用,一起就没有效果了,stylesheet的效果是怎么叠加的哪位大侠能告诉我啊,或者给小弟一个学习的文档啊,一直弄不太明白),万分感谢啊
myComponentTreePtr = new MyTreeWidget(splitter);
myComponentTreePtr->verticalScrollBar()->setStyleSheet("background-color: rgb(255,25,125);\ ");
myComponentTreePtr->verticalScrollBar()->setStyleSheet("up-arrow:vertical{\ background-color: rgb(255,255,0);\border: 2px solid grey;\width: 3px;\height: 3px;\}");
#1 [wd007 09-20 21:33]
以下这些可能有用:
QTreeView {
alternate-background-color: yellow;
}
QTreeView {
show-decoration-selected: 1;
}
QTreeView::item {
border: 1px solid #d9d9d9;
border-top-color: transparent;
border-bottom-color: transparent;
}
QTreeView::item:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
border: 1px solid #bfcde4;
}
QTreeView::item:selected {
border: 1px solid #567dbc;
}
QTreeView::item:selected:active{
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
}
QTreeView::item:selected:!active {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
}
The branches of a QTreeView are styled using the ::branch subcontrol. The following stylesheet color codes the various states when drawing a branch.
QTreeView::branch {
background: palette(base);
}
QTreeView::branch:has-siblings:!adjoins-item {
background: cyan;
}
QTreeView::branch:has-siblings:adjoins-item {
background: red;
}
QTreeView::branch:!has-children:!has-siblings:adjoins-item {
background: blue;
}
QTreeView::branch:closed:has-children:has-siblings {
background: pink;
}
QTreeView::branch:has-children:!has-siblings:closed {
background: gray;
}
QTreeView::branch:open:has-children:has-siblings {
background: magenta;
}
QTreeView::branch:open:has-children:!has-si ..
#2 [kevin_wmy 09-21 10:53]
谢楼上,这个我也看过,实验过,就是比如myComponentTreePtr->verticalScrollBar()->setStyleSheet("background-color: rgb(255,25,125);\ ");有效,但设置响应的滑块和箭头就没有效果,甚至连背景的设置都被弄没了,所以如果有什么介绍stylesheet在各个组件同时用效果是怎么叠加的麻烦大侠们不吝赐教啊,比如tabwidget设置了,然后再QStackedWidget和QTabBar::tab:selected结果tabwidget的背景都没了
tabwidget->setStyleSheet("background-color: rgb(202,207,216);");
tabwidget->setStyleSheet("QStackedWidget{\
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,stop: 0 #838996, stop: 1 #CACFD8);\
border:1px solid transparent;\
} ");
tabwidget->setStyleSheet("QTabBar::tab:selected{\
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,stop: 0 #838996, stop: 1 #CACFD8);\
border:1px solid transparent;\
&nb ..