I'm trying to get kinetic scroll on a widget using Qt 5.1's QScroller class but it does not work when i use "TouchGesture" when deployed to device. The "LeftMouseButtonGesture" gesturetype works properly on desktop as well as the android device. I'm unsure whether my code is correct or wrong.

Following is my code:

Qt Code:
  1. Dialog::Dialog(QWidget *parent) :
  2. QDialog(parent),
  3. ui(new Ui::Dialog)
  4. {
  5. ui->setupUi(this);
  6. resize(800,480);
  7.  
  8. QScrollArea *scroll = new QScrollArea(this);
  9. scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  10. scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  11.  
  12. QWidget *viewport = new QWidget(this);
  13. scroll->setWidget(viewport);
  14. scroll->setWidgetResizable(true);
  15.  
  16. QVBoxLayout *l = new QVBoxLayout(viewport);
  17. viewport->setLayout(l);
  18.  
  19. for(int i = 0; i < 100; i++)
  20. {
  21. QLabel *lb = new QLabel();
  22. lb->setText("Label "+QString::number(i));
  23. lb->setStyleSheet("border-radius: 5px;"
  24. "color: #FAFAFA;"
  25. "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
  26. "stop: 0 #a6a6a6, stop: 0.08 #7f7f7f,"
  27. "stop: 0.39999 #717171, stop: 0.4 #626262,"
  28. "stop: 0.9 #4c4c4c, stop: 1 #333333);"
  29. );
  30. l->addWidget(lb);
  31. }
  32.  
  33. QVBoxLayout *dialog_layout = new QVBoxLayout(this);
  34. dialog_layout->addWidget(scroll); // add scroll to the QDialog's layout
  35. setLayout(dialog_layout);
  36. show();
  37.  
  38. QScroller::grabGesture(scroll, QScroller::TouchGesture); //Replace TouchGesture with LeftMouseButtonGesture and it works flawlessly
  39. }
To copy to clipboard, switch view to plain text mode