I have a QWidget, which may be a window, with a title bar and frame, or it may be a simple control such as a button or a frame.
How do I write code to query the title bar height such that I get the right result - i.e. the system title bar height if it's a window with one, or 0 otherwise?
开发者_C百科I tried using the QStyle pixel metrics, but it always returns the system value:
QStyleOptionTitleBar option;
option.initFrom(widget);
captionHeight = widget->style()->pixelMetric(QStyle::PM_TitleBarHeight, &option, widget);
Use widget::isWindow()
to tell if the widget is in it's own window - then use what you've got
精彩评论