Kinetic scrolling on QTableView, randomly selecting row.
-
Hi, I need some help and I am struggling to solve this problem. I am implementing kinetic scrolling on a QTableView and I also need row selection feature. Once the row is selected I show some details about that row. Also row has delegate assigned for the view purpose.
However, my problem is when user is scrolling via touch, it's selecting one of the row by default and it shows the detail of that row as per my specs. But now here problem is user dint select row. he/she is just scrolling but I guess when user is releasing the touch its consider as a mouse released for the Table view and selecting that row.is there any way i can avoid this or any other implementation I can do to achieve this.
Here is my sample code for the kinetic scrolling and row selection
QScroller *scroller = QScroller::scroller(view);
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
//view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);QScrollerProperties properties =
QScroller::scroller(scroller)->scrollerProperties();
QVariant overshootPolicy =
QVariant::fromValueQScrollerProperties::OvershootPolicy(
QScrollerProperties::OvershootAlwaysOff);properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, overshootPolicy);
scroller->setScrollerProperties(properties);
properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, overshootPolicy);
scroller->setScrollerProperties(properties);
scroller->grabGesture(view, QScroller::TouchGesture);view is QTableView instance here.
// this is how I am using row selection signal
void TableWidget::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
emit sig_selectionChanged(selectedIndexes());
}any help appreciated. Thank you in advance.
-
Hi and welcome to devnet,
You should add which version of Qt you are using as well as the platform.
A full minimal compilable example would be better so people can test the same things as you.
-
Hi and welcome to devnet,
You should add which version of Qt you are using as well as the platform.
A full minimal compilable example would be better so people can test the same things as you.
@SGaist
Thanks for replying. I am using qt 5.12.8 and linux ubuntu platform. -
If possible you should test with a more recent version.