Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.6.3
-
None
-
OS X 10.5.8, Qt 4.6.3, Intel dual Quad-core Mac Pro.
Description
I need to line up windows having titlebar with windows having no titlebar. To account for the titlebar, I need the height of a standard window titlebar, so I use QStyle::pixelMetric().
Here's my code using pixelMetric():
QStyle * wStyle = style(); QStyleOptionTitleBar so; so.titleBarState = 1; // kThemeStateActive so.titleBarFlags = Qt::Window; int titleBarHeight = wStyle->pixelMetric(QStyle::PM_TitleBarHeight, &so, this);
On a Macintosh titleBarHeight is coming back as 26.
I see in the code for QMacStyle::pixelMetric():
case PM_TitleBarHeight: if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { HIThemeWindowDrawInfo wdi; wdi.version = qt_mac_hitheme_version; wdi.state = kThemeStateActive; wdi.windowType = QtWinType; if (tb->titleBarState) wdi.attributes = kThemeWindowHasFullZoom | kThemeWindowHasCloseBox | kThemeWindowHasCollapseBox; else if (tb->titleBarFlags & Qt::WindowSystemMenuHint) wdi.attributes = kThemeWindowHasCloseBox; else wdi.attributes = 0; wdi.titleHeight = tb->rect.height(); wdi.titleWidth = tb->rect.width(); QCFType<HIShapeRef> region; HIRect hirect = qt_hirectForQRect(tb->rect); if (hirect.size.width <= 0) hirect.size.width = 100; if (hirect.size.height <= 0) hirect.size.height = 30; HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, ®ion); HIRect rect; ptrHIShapeGetBounds(region, &rect); ret = int(rect.size.height); ret += 4; } break;
Note at the bottom where it adds 4 to the result!
Why?