Hello,
I have problem with the touch screen (Win 8.1 - full win - 10' tablet) and touch events.
1. QScroller - basically everything working fine, except that when placing scroller on i.e. viewport for the QTreeView I can't resize rows when content exceed visible area - QScroller kick in and move view - probably subclass and event propagation would fix that. But what I cant figure out is speed for scroller.
Question - how to slow dont scroller? My code for scroller:
QScroller *scroller = QScroller::scroller(ui_->treeView->viewport());
QScrollerProperties prop = scroller->scrollerProperties();
prop.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
prop.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
prop.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
prop.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
prop.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.93);
prop.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
scroller->setScrollerProperties(prop);
scroller->grabGesture(ui_->treeView, QScroller::TouchGesture);
scroller->grabGesture(ui_->treeView, QScroller::LeftMouseButtonGesture);
QScroller *scroller = QScroller::scroller(ui_->treeView->viewport());
QScrollerProperties prop = scroller->scrollerProperties();
prop.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
prop.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
prop.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
prop.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
prop.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.93);
prop.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
scroller->setScrollerProperties(prop);
scroller->grabGesture(ui_->treeView, QScroller::TouchGesture);
scroller->grabGesture(ui_->treeView, QScroller::LeftMouseButtonGesture);
To copy to clipboard, switch view to plain text mode
Basically when I move by mouse it's work fast but when I use touch screen then its "ultra" fast. Tree contains file model so there is a lot of items and I can move to bottom with single touch move.
2. Touch events wrong values:
I want to move widget by touch event. So I do accept touch event on the widget and then on events I do calculate delta and move my widget. It's working fine when using mouse, but when using touch I got big delta.
{
mPos_ = e->pos();
}
{
if (e->buttons() & Qt::LeftButton && !this->isFullScreen()) {
this->move(mapToParent(mP));
}
void MainWindow::mousePressEvent(QMouseEvent *e)
{
mPos_ = e->pos();
}
void MainWindow::mouseMoveEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::LeftButton && !this->isFullScreen()) {
QPoint mP = e->pos() - mPos_;
this->move(mapToParent(mP));
}
To copy to clipboard, switch view to plain text mode
Delta sometimes is 200x100 pix etc. Why? This happens only on touch screen. Also what's strange is that mouse press event is registered twice and what I do is touch screen and slowly move. It's not always but sometimes.
Any suggestions are more then welcome.
PS. Tested on Win 8 / Win 8.1 with Qt 5.1.1 and 5.2 with MSVC2010 and MinGW. 32 bit all.
Bookmarks