Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get scroll bar real width in Qt?

Tags:

scrollbar

qt

I'm trying to make a custom widget, which is basically a bunch of textedits with a single vertical scroll bar on the right. To keep widget size determined, I have to find a width of the scrollbar, as texedits geometry depends on it. Simply calling scroll_bar->width(); for freshly created vertical bar returns 101, which is obviuosly wrong.

So, is there a way to determine vertical scroll bar width correctly in Qt 3.2.3?

like image 676
akalenuk Avatar asked May 13 '13 05:05

akalenuk


2 Answers

int w = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
like image 149
hank Avatar answered Oct 08 '22 22:10

hank


I've also found

vsb->sliderRect().width(); 

which happens to be correct, but it looks bad in the code, as I have no interest in slider per se.

like image 35
akalenuk Avatar answered Oct 08 '22 22:10

akalenuk