开发者

How can I add scrollable whitespace at the bottom of a QTreeView

When expanding an item at the bottom of a QTreeView, the view does not automatically scroll to show the newly-expanded items. I can fix this by detecting expansion and performing the scroll myself when appropriate.

However, I would instead like to allow the user to scroll the view farther than is currently allowed开发者_如何学Go. Currently, if the tree is too tall to fit in the visible area, the view can be scrolled only until the bottom-most row comes into view.

I believe this should be doable by tricking the QTreeView's size calculation, but even after source diving I don't understand the interaction between QTreeView and its base QAbstractScrollArea well enough to know what to poke, or where to start poking.

If all else fails I may just add some dummy, non-editable rows to my data model.


you can add extra white space to the treeview by increasing its vertical scrollbar maximum value. Smth like this:

max = self.treeview.verticalScrollBar().maximum()
self.treeview.verticalScrollBar().setMaximum(max*2)

hope this helps, regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜