[英]set line between qtreewidget items
I have a QTreeWidget
that items append to it dynamically, I want to set lines between them, I have first pictures and I want it to be like the second one, but I don't know how doing it? 我有一个
QTreeWidget
,项目可以动态地追加到它之间,我想在它们之间设置行,我有第一张图片,并且希望它像第二张图片一样,但是我不知道该怎么做? thank you in advance! 先感谢您!
Well you can experiment with stylesheets: 好吧,您可以尝试使用样式表:
treeWidget->setStyleSheet("QTreeWidget::item { border-bottom: 1px solid black;}");
But I am not sure if can get exactly the look you want. 但是我不确定是否可以得到您想要的外观。 You can also subclass QStyledItemDelegate and provide your own
sizeHint()
and paint()
implementations. 您还可以继承QStyledItemDelegate的子类,并提供自己的
sizeHint()
和paint()
实现。
If You need to select items, following works a little better I think: 如果您需要选择项目,我认为以下方法会更好一些:
QString style = "QTreeWidget::item:!selected "
"{ "
"border: 1px solid gainsboro; "
"border-left: none; "
"border-top: none; "
"}"
"QTreeWidget::item:selected {}";
allergiesListView->setStyleSheet(style);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.