how to enable the QListWidget support touch event
-
As the title.
Do not use the scroll bar to navigate the item, but just touch the screen to scroll up and down.Or any other options to implement a list that support touch?(not qml)
-
re-implement a QListWidget class with mouseMove, mouseRelease and mousePress events
-
Yes. I do the same. stupid.
-
Do you have to use a QListWidget? If you can use QML instead, try a flickable element.
/edit: hrm, I clearly didn't read your question thoroughly; you said you can't use QML. -
Perhaps you should also look for the "flick charm" that was written a few years ago. It could still serve to inspire you.
-
I stucked with this issue since months ago :(
May some one help us here and contribute with small snippet?
-
-
[quote author="ltr6" date="1399363630"]Try QScroller:
http://qt-project.org/doc/qt-5/qscroller.html
This might also help:
http://qt-project.org/forums/viewthread/38529[/quote]
Thank you; but I really didn't understand how can I make my QListWidget supports Touch. I really need some simple snippet.
-
There was a snippet, I'll paste it here:
@QScrollerProperties sp;
sp.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.6);
sp.setScrollMetric(QScrollerProperties::MinimumVelocity, 0.0);
sp.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.5);
sp.setScrollMetric(QScrollerProperties::AcceleratingFlickMaximumTime, 0.4);
sp.setScrollMetric(QScrollerProperties::AcceleratingFlickSpeedupFactor, 1.2);
sp.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.2);
sp.setScrollMetric(QScrollerProperties::MaximumClickThroughVelocity, 0);
sp.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
sp.setScrollMetric(QScrollerProperties::MousePressEventDelay, 0.5);QScroller* scroller = QScroller::scroller(yourListWidget);
scroller->grabGesture(yourListWidget, QScroller::LeftMouseButtonGesture);
scroller->setScrollerProperties(sp);@
On lines 13 and 15 you need to give your list widget as the parameter.
-
Thank you a lot; I didn't expect it very easy. I thought the pointed code works for scrolling only.
xhsoldier. May you please set this thread as [SOLVED]