[英]How to repaint QTreeWidget?
I have QTreeWidget . 我有QTreeWidget 。 In which I'm adding new column dynamically on button click event using setHeaderLabels . 在其中,我使用setHeaderLabels在按钮单击事件上动态添加新列。 This API add new column in TreeWidget
but column is not visible in current TreeWidget
area. 该API在TreeWidget
添加了新列,但该列在当前TreeWidget
区域中不可见。 It adds a scroll bar in TreeWidget
. 它在TreeWidget
添加了一个滚动条。 Therefore to view newly added column user has to scroll the tree. 因此,要查看新添加的列,用户必须滚动树。 This my scenario but I don't want to scroll. 这是我的情况,但我不想滚动。 I have used update() function even though its not showing new column. 我使用过update()函数,即使它没有显示新列。 Is there any way to repaint the widget. 有什么办法可以重画窗口小部件。 Thank you ! 谢谢 !
Call 呼叫
treeWidget->header()->setStretchLastSection(false);
at the initialization and 在初始化和
treeWidget->resizeColumnToContent(column);
each time your adding a column. 每次您添加一列。
Looks like 看起来像
resizeColumnToContents(int col)
will help you. 会帮助你。 (You should call it every time after adding new column) (您应该在添加新列后每次调用它)
Btw, don't forget to call 顺便说一句,别忘了打电话
header()->setStretchLastSection(false)
on initialization of TreeView 关于TreeView的初始化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.