Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, June 2007
Behavior changed for QGV scrollbars


Message 1 in thread

Hello,

I was used (with Qt4.2 and before) to have a QGV with hidden scrollbars 
(ScrollBarAlwaysOff) but that was scrolled with
frame-> verticalScrollBar()->setValue ( yyy )
when the mouse is near one of the window borders. 
Since Qt4.3, this behavior has changed. Now, minimum and maximum values for 
the scrollbars are both 0 and thus asking for a change has no effect.

I think that this is a bug, but maybe should I use another method to do this 
scrolling ?

Note that if I enable the scroll bars (ScrollBarAlwaysOn) and hide them with 
hide(), then it works but there is as expected an ugly gray zone at the bars 
positions.

Best regards,

Kleag
-- 
 [ signature omitted ] 

Message 2 in thread

Kleag a Ãcrit :
> Hello,
> 
> I was used (with Qt4.2 and before) to have a QGV with hidden scrollbars 
> (ScrollBarAlwaysOff) but that was scrolled with
> frame-> verticalScrollBar()->setValue ( yyy )
> when the mouse is near one of the window borders. 
> Since Qt4.3, this behavior has changed. Now, minimum and maximum values for 
> the scrollbars are both 0 and thus asking for a change has no effect.
> 
> I think that this is a bug, but maybe should I use another method to do this 
> scrolling ?
> 
> Note that if I enable the scroll bars (ScrollBarAlwaysOn) and hide them with 
> hide(), then it works but there is as expected an ugly gray zone at the bars 
> positions.
> 
> Best regards,
> 
> Kleag


Hi,

This has already been reported and fixed. Take a look at task 163919.
I attached the patch I get from Trolls.
--- src/gui/graphicsview/qgraphicsview.cpp	2007-06-08 15:04:47 -0000
--- src/gui/graphicsview/qgraphicsview.cpp	2007-06-08 15:04:47 -0000
+++ src/gui/graphicsview/qgraphicsview.cpp	2007-06-08 15:04:47 -0000

@@ -410,7 +410,9 @@
 
     // If the whole scene fits horizontally, we center the scene horizontally,
     // and ignore the horizontal scroll bars.
-    if (!useHorizontalScrollBar) {
+    int left = int(qMax<qreal>(viewRect.left(), INT_MIN));
+    int right = int(qMin<qreal>(viewRect.right() - width, INT_MAX));
+    if (left >= right) {
         q->horizontalScrollBar()->setRange(0, 0);
 
         switch (alignment & Qt::AlignHorizontal_Mask) {
@@ -426,17 +428,17 @@
             break;
         }
     } else {
-        int left = int(qMax<qreal>(viewRect.left(), INT_MIN));
-        int right = int(qMin<qreal>(viewRect.right() - width + 1, INT_MAX));
         q->horizontalScrollBar()->setRange(left, right);
         q->horizontalScrollBar()->setPageStep(width);
         q->horizontalScrollBar()->setSingleStep(width / 20);
         leftIndent = 0;
     }
 
-    // If the whole scene fits vertical, we center the scene vertically, and
+    // If the whole scene fits vertically, we center the scene vertically, and
     // ignore the vertical scroll bars.
-    if (!useVerticalScrollBar) {
+    int top = int(qMax<qreal>(viewRect.top(), INT_MIN));
+    int bottom = int(qMin<qreal>(viewRect.bottom() - height, INT_MAX));
+    if (top >= bottom) {
         q->verticalScrollBar()->setRange(0, 0);
 
         switch (alignment & Qt::AlignVertical_Mask) {
@@ -452,8 +454,6 @@
             break;
         }
     } else {
-        int top = int(qMax<qreal>(viewRect.top(), INT_MIN));
-        int bottom = int(qMin<qreal>(viewRect.bottom() - height + 1, INT_MAX));
         q->verticalScrollBar()->setRange(top, bottom);
         q->verticalScrollBar()->setPageStep(height);
         q->verticalScrollBar()->setSingleStep(height / 20);


Message 3 in thread

Hello,

Thanks. Your patch works for me too. Sorry for the noise.

Best reagards,

Kleag
Le lundi 11 juin 2007, alexandre.raczynski@technog a ÃcritÂ:
> Kleag a Ãcrit :
> > Hello,
> >
> > I was used (with Qt4.2 and before) to have a QGV with hidden scrollbars
> > (ScrollBarAlwaysOff) but that was scrolled with
> > frame-> verticalScrollBar()->setValue ( yyy )
> > when the mouse is near one of the window borders.
> > Since Qt4.3, this behavior has changed. Now, minimum and maximum values
> > for the scrollbars are both 0 and thus asking for a change has no effect.
> >
> > I think that this is a bug, but maybe should I use another method to do
> > this scrolling ?
> >
> > Note that if I enable the scroll bars (ScrollBarAlwaysOn) and hide them
> > with hide(), then it works but there is as expected an ugly gray zone at
> > the bars positions.
> >
> > Best regards,
> >
> > Kleag
>
> Hi,
>
> This has already been reported and fixed. Take a look at task 163919.
> I attached the patch I get from Trolls.



-- 
 [ signature omitted ]