Important: Please read the Qt Code of Conduct -

[mobile][touch events] How to scroll listwidget after "flicking" on device?

  • Developing for android smartphones, I've got a QListWidget that shows items and I just want to allow users to scroll the list by swiping up or down anywhere in the list, not just on the scrollbar. I've installed my event filter and I can capture TouchEvents and I can scroll, but my problem is that as soon as user is no longer touching the device, the scroll stops dead. I want it to be like most other mobile apps that allow the list to continue scrolling, after finger is lifted, for a short distance depending on how fast the user swiped.

    Does anybody have any idea how this can be done?

    Here is relevant excerpt from my event filter, once I've accepted the TouchBegin event, I perform the scrolling in the TouchUpdate event. I'm guessing I should do the scrolling after user lifts finger in TouchEnd event, but I have no idea how I would do that, how does one capture the speed and direction at which user swiped?

        case QEvent::TouchUpdate:
            touchEvent = static_cast<QTouchEvent*>(event);
            QTouchEvent::TouchPoint tp = touchEvent->touchPoints()[0];
            QPointF lastpos = tp.lastPos();
            QPointF curpos = tp.pos();
            qreal dy = curpos.y() - lastpos.y();
            int crnt = ui->myList->verticalScrollBar()->value();
            ui->myList->verticalScrollBar()->setValue(crnt - dy);
            return true;


  • Moderators

    Hi @Snorkelbuckle,

    I suggest you take a look at QScroller, if you have this call grabGesture() on the QListWidget's viewport then it should give you what you want without having to handle the touch events yourself. See for more.

Log in to reply