Reputation: 1125
Pressing on Qml Button with mouse or finger(on touch enabled device) and moving too much will not emit pressAndHold() signal.
pressAndHold()
This signal is emitted when the button is interactively pressed and held down by the user via touch or mouse.
Moving very few pixels would emit pressAndHold() signal but it seems the threshold is very small and it is very apparent problem on touch enabled device where finger naturally moves a little when pressing on button. Therefore pressAndHold() signal would not be emitted reliably.
Upvotes: 0
Views: 1272
Reputation: 1125
Set startDragDistance property to higher than default value(10)
QGuiApplication::styleHints()->setStartDragDistance(100);
Looking at the QQuickAbstractButton source code one can find method:
void QQuickAbstractButtonPrivate::handleMove(const QPointF &point)
void QQuickAbstractButtonPrivate::handleMove(const QPointF &point)
{
Q_Q(QQuickAbstractButton);
QQuickControlPrivate::handleMove(point);
setMovePoint(point);
q->setPressed(keepPressed || q->contains(point));
if (!pressed && autoRepeat)
stopPressRepeat();
else if (holdTimer > 0 && (!pressed || QLineF(pressPoint, point).length() > QGuiApplication::styleHints()->startDragDistance()))
stopPressAndHold();
}
When distance from starting point to moved point is greater than QGuiApplication::styleHints()->startDragDistance()
threshold stopPressAndHold()
is called cancelling press and hold action.
Upvotes: 2