QTreeView - Horizontal scroll bar is not working properly
-
Hi,
I am facing difficulties with the horizontal scroll bar in Qtreeview.
When I expand and the content exceeds the widget, I expect that scroll bar should appear.
projectTreeView->header()->setMinimumWidth(1000); projectTreeView->header()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); projectTreeView->setTextElideMode(Qt::ElideNone); projectTreeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); projectTreeView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); projectTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); projectTreeView->setSelectionMode(QAbstractItemView::SingleSelection); projectTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
These are the properties I have set.
What happens is that,
After crossing 1000, I do get a scroll bar, but, it doesn't grow as when I keep expanding the tree.How do I get the better control?
Thanks,
Kumara -
Hi,
Out of curiosity, why do you need to modify your header ?
-
@SGaist I thought that's the way to get the control on sizing.
If that is not correct, can you please recommend me the right way?
Thanks,
Kumara -
AFAIK, by default the QTreeView will do what you want without any special handling. What model are you using ?
-
AFAIK, by default the QTreeView will do what you want without any special handling. What model are you using ?
@SGaist Am using QStandardItemModel..
-
@SGaist Am using QStandardItemModel..
@kumararajas When I did a quick test, QTableView and QListView works good with respect to horizontal scroll bar.
But, QTreeView is having some problems around. Not sure why.
Can you please share any example or sample code where Horizontal scroll bar works good in QTreeView? I can use that as my reference and check what am I doing wrong.
Thanks,
Kumara -
This is still open.
Any thoughts on this problem?
-
Can you provide a minimal compilable sample application that triggers that ?
-
@SGaist Good question :)
I have the implementation as part of my project. Let me see if I have strip of my code from the same and share it here. Else, I can also try a sample application which can reproduce this problem and share it here.