【问题标题】:QTreeWidget expand signQTreeWidget 展开符号
【发布时间】:2010-04-14 15:59:29
【问题描述】:

即使项目没有任何子项目,如何使 QTreeWidget 中的可扩展登录始终可见?以及如何绘制其他东西而不是默认符号?

提前致谢, 塞尔吉

【问题讨论】:

  • 我不知道你问题第二部分的答案。 (我建议再次提出一个单独的问题。),但我认为这将涉及 QTreeView 和一个委托,这可能比仅仅坚持默认的工作要多得多。

标签: qt pyqt


【解决方案1】:

QTreeWidgetItems 有property childIndicatorPolicy。允许的值为:

  • QTreeWidgetItem::ShowIndicator
  • QTreeWidgetItem::DontShowIndicator
  • QTreeWidgetItem::DontShowIndicatorWhenChildless

你想要第一个。

theItem.setChildIndicatorPolicy(QTreeWidgetItem.ShowIndicator)

【讨论】:

  • 非常感谢,它有帮助,对于我的问题的第二部分 - 我自己找到了解决方案
  • 当它有孩子时如何隐藏指示器?
【解决方案2】:

为其他人回答我的第二部分问题。

我在 QTreeView 中寻找绘图功能,发现如下:

void QTreeView::drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) 

使用此功能,您可以在每个项目的左侧绘制您想要的任何内容。

另外一个很好的选择——使用 QTreeView 的样式表:

http://qt.nokia.com/doc/4.6/stylesheet-examples.html#customizing-qtreeview

【讨论】:

    猜你喜欢
    • 2012-10-29
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多