如何找到QDockWidget标题栏的高度? [英] How to find the height of a QDockWidget title bar?

查看:677
本文介绍了如何找到QDockWidget标题栏的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到QDockWidget标题栏的高度,以便对自定义布局进行智能调整,但是标题栏不是单独的窗口小部件,而是内置在停靠窗口小部件的专用布局中,并且没有成员可以访问它.还有其他方法可以找到它的高度吗?

I'm trying to find the height of a QDockWidget title bar in order to do some intelligent sizing of a custom layout, but the title bar is not a separate widget, it's built into the private layout of the dock widget, and there is no member to access it. Is there some other way to find its height?

推荐答案

是的,您可以使用停靠栏QStyle元素的pixelMetric成员函数找到标题栏的高度.您可能还需要查询页边距,因为它在标题栏周围增加了空间,并且布局需要注意这一点.示例:

Yes, you can find the title bar's height using the pixelMetric member function of the dock's QStyle element. You'll probably also want to query the margin as well since it adds space around the title bar and the layout will need to be aware of it. Example:

QDockWidget * myDock = new QDockWidget;
int titleBarHeight = myDock->style()->pixelMetric(QStyle::PM_TitleBarHeight);
int titleBarMargin = myDock->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin);

这篇关于如何找到QDockWidget标题栏的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆