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

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:


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

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.

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