Kinetic Scrolling on QScrollarea on Android device ..
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); sa->setFrameStyle(QFrame::NoFrame); sa->setFrameShadow(QFrame::Plain); sa->setWidgetResizable(true); sa->resize(800,480); ScrollContentDialog *m_diag = new ScrollContentDialog(sa); // Contains a loop where i add 50 QLabels m_diag->setMinimumSize(0,(50*30)); m_diag->show(); sa->setWidget(m_diag); sa->show();
// QListWidget *m_list = new QListWidget(this);
// 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
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
doesn’t work for QScrollArea. Then I used a class called FlickCharm [blog.qt.digia.com]. It was developed by Ariya Hidayat [blog.qt.digia.com] 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:
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.