Kinetic Scrolling on QScrollarea on Android device ..

  • Moderators


    I want to enable kinetic scrolling on a QScrollArea, so as per the Qt5.1 docs i used
    But the scroll does not happen at all on the device, it works on using QScroller::LeftMouseButtonGesture.
    I have also done setAttribute(Qt::WA_AcceptTouchEvents,true) for the scrollarea.

    Any thing more that i need to enable ?


    Kinetic scrolling using QScroller works on QListWidget.
    How to make it work on QScrollArea?

    Following is my test code:

    QScrollArea *sa = new QScrollArea(this);
    ScrollContentDialog *m_diag = new ScrollContentDialog(sa);  // Contains a loop where i add 50 QLabels

    // QListWidget *m_list = new QListWidget(this);
    // m_list->setGeometry(0,0,800,480);
    // m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    // for (int i = 0; i < 200; ++i)
    // new QListWidgetItem(QString("This is a test text %1 %2").arg(i).arg(QString("--------").left(i % 8)), m_list);

    QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(sa); // Replace here m_list for QListWidget test
    QScroller::grabGesture(area->viewport(), QScroller::TouchGesture);

  • Please use "code" tags. It is just hard to read you test code...

  • I'd recommend you to use QML for this

  • Hey everyone,
    I have the same problem here. I can't not make the QScrollArea works with gesture actions. My problem is exactly the same. I did everything like you but it isn't working. I'm using Qt 5.3.1 on Windows and a Samsung Galaxy S4 for tests. If someone found the solution, please share with us. Sincerely,

  • Hey every one. I figured out the problem. For some Reason the code
    QScroller::grabGesture(this->ui->scrollArea->viewport(), QScroller::TouchGesture);
    doesn’t work for QScrollArea. Then I used a class called FlickCharm []. It was developed by Ariya Hidayat [] and it is working good now.
    Not satisfied I tried to use the QScroller again but this time with the parameter QScroller::LeftMouseButtonGesture that is:
    @QScroller::grabGesture(this->ui->scrollArea->viewport(), QScroller::LeftMouseButtonGesture);@

    and…. It works for Mouse Event and for Touch Event on my Samsumg Galaxy S4. Now I’m happy because I’m just using the native class QScroller and it’s working so good. I hope to help more people in the same situation. Sincerely.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.