QScroller Kinetic scrolling is not smooth
Tsweti last edited by
Kinetic scrolling is very important for developing mobile applications with Qt and I noticed that it's not smooth on the devices ( tried with android device and iphone ) . It looks a bit choppy and jumping as it looks from one position to the next one. This is visible especially when trying to scroll slow with the finger. The other applications in the devices are scrolling a lot smoother especially in iphone.
I made a simple test project with QFrame ( ui->frame ) containing only buttons. The buttons are added to QVBoxLayout. This frame is added to QcrollArea object which reacts to touch events. And this scrollArea is added to QGridLayout. So the scrolling is only in vertical direction.
I have this code in the constructor of my class which is based on QFrame:
ui->frame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
ui->frame->setMinimumHeight( 1000 );
ui->frame->setMaximumHeight( 1000 );
m_scrollArea = new QScrollArea(); m_scrollArea->setWidget( ui->frame ); m_scrollArea->setWidgetResizable( true ); m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_layout = new QGridLayout(); m_layout->addWidget( m_scrollArea ); m_layout->setContentsMargins( 0, 0, 0, 0 ); setLayout( m_layout ); QScroller::grabGesture( m_scrollArea, QScroller::TouchGesture );
Am I doing something wrong in my code and what can I do to fix this thing or this is some Qt limitation. Is someone else experiencing the same thing? I want my application to be looking as native as possible and this choppy scrolling is really not something normal.
If you need more information I will try to provide. I may try to upload my test project somewhere and add some screen capture of the device if needed.
The Qt version that i'm using is 5.1.1 for the android and Qt 5.1.0RC1 self-build for the ios.
Tsweti last edited by
sp.setScrollMetric( QScrollerProperties::DragStartDistance, 0.001 );
sp.setScrollMetric( QScrollerProperties::ScrollingCurve, QEasingCurve::Linear );
QScroller* qs = QScroller::scroller( m_scrollArea );
qs->setScrollerProperties( sp );@
The DragStartDistance makes the scrolling more responsive. What other property can I fine tune to make the scrolling look better?
I also noticed that the GUI paintEvent() is not called every time the QEvent::Scroll is received from the QScrollArea which I guess may lead to choppy scrolling. So I added code to repaint the GUI every time I receive QEvent::Scroll and the scrolling looks little smoother but still not perfect in the android device.
What else can I try?
plinioandrade last edited by
The solution for you problem is here:
Take a look in my post there. My QScroller is working fine now!
Here is the Qt Code in case the link breaks:
Try setting the verticalScrollMode of your view to ScrollPerPixel>