Hi,
I'm trying to resize a QListWidget to it's content with QFontMetrics, calculating the height and the width. The calculating of the width works perfectly, but it fails to calculate the right height.
QFont font
("Droid Sans",
12,
false);
int width = fm.width() * longestEntry + 10;
int height = fm.height() * widget.count() + 10;
widget->resize(width, height);
QListWidget *widget = new QListWidget(this);
QFont font("Droid Sans", 12, false);
QFontMetrics fm(font);
int width = fm.width() * longestEntry + 10;
int height = fm.height() * widget.count() + 10;
widget->resize(width, height);
To copy to clipboard, switch view to plain text mode
The problem is, that the space between the QListWidgetItems depends on the used font and QFontMetrics delivers only the height without the space.

Is it possible to get these extra pixels so I can calculate the right height with
int height = (fm.height() + pixels) * widget.count();
int height = (fm.height() + pixels) * widget.count();
To copy to clipboard, switch view to plain text mode
Or is there another (better) way to resize the QListWidget to it's content?
Many thanks!
Bookmarks