PDA

View Full Version : detecting the width of column needed to display data



mentalmushroom
17th March 2011, 16:43
Hello. How to calculate the width of column to display data without ellipsis?

I noticed if I try something like this:


ui.treeView->header()->resizeSection(DOWNLOADS_COL_SPEED, QFontMetrics(ui.treeView->font()).width(tr("881.20 Kb/s")));


Exactly the same value (I mean 881.20 Kb/s) may be displayed with ellipsis for some users. What is my mistake?

Also I noticed that columns with ResizeMode = QHeaderView::ResizeToContents not always change its width correctly.