Kinetic scrolling on a qlistwidget select items
-
Hi all. I am struggling with a very basic thing, the kinetic scrolling on a QListWidget. The thing is, i have a list of items which represents links to others pages. I would like the user to be able to scroll using fingers, so for that i used
@QScroller::grabGesture(m_list,QScroller::TouchGesture);@
with m_list being my QListWidget.
The problem is that when i scroll using my finger, the point where i touch the screen to start the scroll actually select an item (the item in question get the blue color, meaning it has been selected) so when I release the screen, if my finger was on an item, the signal itemPressed() is triggered, which is a problem.
I already saw another Qt application where the app recognized the difference between a real touch and a scroll.I tried several solutions, like with the signal itemActivated() instead of itemPressed() or itemClicked(). The first doesn't even trigger when i touch the item.
Does somebody knows the easy way? Thanks by advance.
-
Hey there ! Yes, i managed to "cheat" for that. I don't remember exactly (and i don't have access to my code anymore) but i linked my QScroller::stateChanged to a slot i made to check the current state (inactif, dragging, etc...). There, i used a QTimer and a bool or something like that to autorize or not the app to do the action linked to the clic on the list.
If i recall properly, it's because the onItemClicked signal is emitted when the user's finger release the screen, and not when he touch it. So, if there was a time too long between the touch on the screen and the release of the finger, I blocked the onItemClicked action, assuming the user was just slowly scrolling.
It's not perfect and i don't recall the detail, I still hope it will help you somehow =)