PDA

View Full Version : QScroller speed and touch screen



Talei
21st December 2013, 18:51
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::AxisLock Threshold, 0.66);
prop.setScrollMetric(QScrollerProperties::Scrollin gCurve, QEasingCurve(QEasingCurve::OutExpo));
prop.setScrollMetric(QScrollerProperties::Decelera tionFactor, 0.05);
prop.setScrollMetric(QScrollerProperties::MaximumV elocity, 0.635);
prop.setScrollMetric(QScrollerProperties::Overshoo tDragResistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::Overshoo tScrollDistanceFactor, 0.33);
prop.setScrollMetric(QScrollerProperties::SnapPosi tionRatio, 0.93);
prop.setScrollMetric(QScrollerProperties::DragStar tDistance, 0.001);

scroller->setScrollerProperties(prop);

scroller->grabGesture(ui_->treeView, QScroller::TouchGesture);
scroller->grabGesture(ui_->treeView, QScroller::LeftMouseButtonGesture);

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.


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));
}


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.

sedi
22nd December 2013, 01:23
Try setting the verticalScrollMode of your view to ScrollPerPixel
http://doc.qt.digia.com/qt-maemo/qabstractitemview.html#verticalScrollMode-prop

Talei
22nd December 2013, 23:40
Thanks for the info.

So maybe some one knows about 2 - large delta on touch screen.

pliniofernando
16th July 2014, 15:22
You are a genius!!! Your clue is the solution for a lot of opened posts related to QScroller not smooth. I was looking for a answer about it for days. When you do
setHorizontalScrollMode(QAbstractItemView::ScrollP erPixel); everything works good. Thank you!

Try setting the verticalScrollMode of your view to ScrollPerPixel
http://doc.qt.digia.com/qt-maemo/qabstractitemview.html#verticalScrollMode-prop

smegy
4th November 2014, 11:38
Note that in your code

scroller->grabGesture(ui_->treeView, QScroller::TouchGesture);

is useless as the next line, replace the grab :

scroller->grabGesture(ui_->treeView, QScroller::LeftMouseButtonGesture);