Whow! Thank you very much for the explanation!
I now tried the computation using the QStyle object. My code looks as follows (progress is an instance of type QProgressDialog):
int metricVal
(style
->pixelMetric
(QStyle::PM_TitleBarHeight,
&btn,
&progress
));
QFont displayFont
(font
());
int widthInPixels(fm.width(dlgTitle) + 2 * metricVal);
progress.setMinimumWidth(widthInPixels);
QStyle *style(qApp->style());
QStyleOptionButton btn;
int metricVal(style->pixelMetric(QStyle::PM_TitleBarHeight, &btn, &progress));
QFont displayFont(font());
QFontMetrics fm(displayFont);
int widthInPixels(fm.width(dlgTitle) + 2 * metricVal);
progress.setMinimumWidth(widthInPixels);
To copy to clipboard, switch view to plain text mode
Surprisingly for me this did not lead to a completely visible window title. The resulting minimum width of the QProgressDialog window was still about 20% too small.
I even tried the other QStyle values you mentioned but they led to an even smaller resulting width. The metricVal values returned were these:
QStyle::PM_TitleBarButtonIconSize -- 16 QStyle::PM_TitleBarHeight -- 24 QStyle::PM_TitleBarButtonSize -- 19
QStyle::PM_TitleBarButtonIconSize -- 16
QStyle::PM_TitleBarHeight -- 24
QStyle::PM_TitleBarButtonSize -- 19
To copy to clipboard, switch view to plain text mode
I should mention that I'm developing my Qt application on RedHat Enterprise Linux v. 7.x.
Bookmarks