How to get real scrollbar width in Qt?

I am trying to create my own widget, which is basically a collection of text elements with one vertical scrollbar on the right. To determine the size of the widget, I have to find the width of the scroll bar, since the geometry of texedits depends on it. Just a call to scroll_bar-> width (); for newly created vertical bars returns 101, which is clearly erroneous.

So, is there a way to correctly determine the scrollbar width in Qt 3.2.3?

+4
source share
2 answers
int w = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent); 
+15
source

I also found

 vsb->sliderRect().width(); 

which turns out to be correct, but it looks bad in the code, since I am not interested in the slider as such.

+1
source

Source: https://habr.com/ru/post/1480409/


All Articles