Minimum width for a QTreeWidget in order not to display horizontal scrollbar
-
wrote on 3 Feb 2017, 07:25 last edited by
Hi,
I use a QTreeWidget, a QMdiArea and a QSplitter between them. QTreeWidget has multiple columns and all set to resizeColumnToContents. So after adding some data header width can be updated according to the data. What I want to achieve is to get the minimum width in order not to display horizontal scrollbar so I can resize QSplitter and whole data can be displayed without need a scrollbar.
Regards. -
Hi,
I use a QTreeWidget, a QMdiArea and a QSplitter between them. QTreeWidget has multiple columns and all set to resizeColumnToContents. So after adding some data header width can be updated according to the data. What I want to achieve is to get the minimum width in order not to display horizontal scrollbar so I can resize QSplitter and whole data can be displayed without need a scrollbar.
Regards.wrote on 3 Feb 2017, 08:54 last edited byHi @zapprox
Instead of using resizeColumnToContents, use setColumnWidth(int,int) to every columns.
-
Hi @zapprox
Instead of using resizeColumnToContents, use setColumnWidth(int,int) to every columns.
wrote on 3 Feb 2017, 11:16 last edited by@Venkatesh-V In this option I think I have to calculate the width of the text using QFontMetrics beacause the header text is not static. However resizeColumnToContents already calculates. So I think I'll go on with resizeColumnToContents . Thank you for your response.
-
wrote on 6 Feb 2017, 16:28 last edited by
I was able to get the width of the columns with calling QTreeWidget's header method and then get the section size for each columns. My calls were like; "m_treeWidget->header()->sectionSize(0);" .Besides there were 2 pixels gap for each column that sholud be considered.
1/4