开发者

Qt: How to get pixel metrics for a particular widget

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜