Solved Minimum width for a QTreeWidget in order not to display horizontal scrollbar
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.
Venkatesh V last edited by
Instead of using resizeColumnToContents, use setColumnWidth(int,int) to every columns.
@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.
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.