I try to implement the solution used by QsKineticScroller .
But instead of using an event filter, I want to include touch management directly inside my QListView subclass. So I moved the code from the event filter directly into my overloaded event functions.
Kinetic scrolling is working but I have a problem for detecting the click :
Code:
void MyListView::mouseReleaseEvent(QMouseEvent * mouseEvent)
{
isPressed = false;
// Looks like the user wanted a single click. Simulate the click,
// as the events were already consumed
if( !isMoving )
{
QMouseEvent* mousePress = new QMouseEvent(QEvent::MouseButtonPress,
lastPressPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QMouseEvent* mouseRelease = new QMouseEvent(QEvent::MouseButtonRelease,
lastPressPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
ignoredMouseActions = 2;
QApplication::postEvent(this, mousePress);
QApplication::postEvent(this, mouseRelease);
}
}
It seems those lines :
Code:
QApplication::postEvent(this, mousePress);
QApplication::postEvent(this, mouseRelease);
have no effect when called from mouseReleaseEvent. If called from the event filter it's working.
MyListView (aka this) never receive mousePress / mouseRelease events (i.e. mouseReleaseEvent and mousePressEvent are never called). Do you have an idea why ?