[Qt-interest] Spacing between the content on QTableView and its scrollbars
Marian Ciobanu
ciobi at inbox.com
Fri Dec 12 22:41:22 CET 2008
> QStyle::SH_ScrollView_FrameOnlyAroundContents is what you are looking
> for. It basically states that the scrollbar should be outside the
> content as it is in motif. In Qt pre 4.5, I believe the actual size used
> to be 2 * (the scrollarea framewidth). In 4.5 we have also added
> QStyle::PM_ScrollView_ScrollBarSpacing to allow styles such as QGtkStyle
> to control this distance precisely.
>
> --
> Jens Bache-Wiig - jbache at trolltech.com
> Nokia - Qt Software - Sandakerveien 116, P.O. Box 4332 Nydalen, 0402
> Oslo, Norway
Thank you, Jens
I tried to implement this but I couldn't find a "scrollarea framewidth", so I used DefaultFrameWidth:
spacing = QApplication::style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents) == 0 ?
0 :
2*QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
This works fine on all the styles that I tested with 4.3.1 and 4.4.3 except for Oxygen in openSUSE 11.1, where Oxygen is the default style (on 4.4.3). In that case pixelMetric(QStyle::PM_DefaultFrameWidth) returns "2", meaning 4 pixels after doubling, but there are 6 pixels on the screen, so I guess QStyle::PM_DefaultFrameWidth isn't the right thing to use.
Perhaps Oxygen being a KDE style (and not part of Qt 4.4.3) has something to do with this. I could adjust the value based on what QApplication::style()->metaObject()->className() returns, but it's not nice.
More information about the Qt-interest-old
mailing list