PDA

View Full Version : Calculating the column width in a wiew



lotek
9th November 2011, 18:50
Hello,

How to properly calculate the column width in a view (e.g. QTableView), knowing the longest possible text string?
I've tried to use the QFontMetrics

QFontMetrics fm( myFont );

int colWidth = fm.width(QLatin1String("MyLongestColumnString");

Unfortunately, the column is still too narrow. I suppose a cell has margins, padding etc. How to obtain these values?

Thanks for your help