PDA

View Full Version : How to determine scrollbar width?



bibbinator
6th April 2011, 05:29
How can I find out how wide a scrollbar is at runtime?

I have a table that is sized to perfectly display the contents. Once there is enough items to show a scrollbar, it overlaps my content.

I would like to be able to query the scrollbar width, based on the current style, so that I can make my widget exactly wide enough to accommodate the scrollbar should it appear.

Thank!

JohannesMunk
6th April 2011, 11:23
Hi!

How about:
qDebug() << qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);

Happy coding!

Johannes

bibbinator
6th April 2011, 11:43
Thanks for that.

Cheers!