PDA

View Full Version : How to add a horizontal scrollbar to a treeview?



yangyunzhao
20th August 2009, 09:02
In my program, I use a treeview to show my items.
If I add too many items into my treeview, it will work as:

http://www.qtcentre.org/forum/attachment.php?attachmentid=3595&stc=1&d=1250751476

If there is too many items, the treeview will auto have a verticality scrollbar.
But if one item is too long, why do not the treeview auto have a horizontal scrollbar?

Some net-friend told me


I think it is default QHeaderView behaviour. To change it try something like
...->header()->setStretchLastSection
...->header()->setResizeMode(QHeaderView::ResizeToContents);

It works. But before this code, I doulbe clicked the treeview's item ,it will quick expand.
After add this code, I found it expand slowly very much.
Each item has about 100 children.

spirit
20th August 2009, 09:24
take a look at QAbstractScrollArea::setHorizontalScrollBarPolicy.