Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the height of a QDockWidget title bar?

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?

like image 912
Nicolas Holthaus Avatar asked Oct 16 '14 19:10

Nicolas Holthaus


1 Answers

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);
like image 195
Nicolas Holthaus Avatar answered Sep 19 '22 21:09

Nicolas Holthaus