Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. ListView scroll and flick speed
Forum Update on Monday, May 27th 2025

ListView scroll and flick speed

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
listviewscroll speedflick speedandroidwidgets
1 Posts 1 Posters 389 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Fitndex-developerF Offline
    Fitndex-developerF Offline
    Fitndex-developer
    wrote on last edited by
    #1

    Hello,

    Qt 5.15.3, Creator 4.14.2

    This is compiled for android (clang Multi-Abi) and testing on a physical device (Samsung note 10).

    Problem: the scroll speed and flick speed in the example provided is lightening fast.

    Primary Goal: one for one drag speed. while maintaining contact I would like the list to move at the same speed as my finger.

    Secondary Goal: Tailor the flick speed settings based on the length of the list, for example (if we are 100 items from bottom (or top), this speed, if we are 50 items from bottom, different speed, or something along those lines).

    I've checked documentation at:
    https://doc.qt.io/qt-5/qscroller.html
    https://doc.qt.io/qt-5/qscrollerproperties.html

    ...but I'm not able to figure out how to piece those functions together to achieve this. I need some help.

    MainWindow.CPP

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        QScreen *screen = QApplication::screens().at(0);
        int Hint = screen->availableSize().height();
    
        int nrows = 500;
    
        QWidget *wgt_search_page = new QWidget(this);
    
        QLabel *lbl_search_page_title = new QLabel(this);
        lbl_search_page_title->setFont(QFont("Courier", Hint*0.012));
        lbl_search_page_title->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        lbl_search_page_title->setText("Exercise Search Results");
    
        QVBoxLayout *vbx_search_page = new QVBoxLayout(this);
        wgt_search_page->setLayout(vbx_search_page);
    
        QListView *lvw_exercise_search = new QListView();
        QStandardItemModel *model = new QStandardItemModel(nrows, 1, this);
    
        int count = 0;
            do{
                QString name = "Exercise " + QVariant(count).toString();
                QStandardItem *item = new QStandardItem(name);
                model->setItem(count, 0, item);
                count++;
            }while(count<nrows);
    
        lvw_exercise_search->setModel(model);
        QScroller::grabGesture(lvw_exercise_search, QScroller::TouchGesture);
        vbx_search_page->addWidget(lbl_search_page_title);
        vbx_search_page->addWidget(lvw_exercise_search);
    
        setCentralWidget(wgt_search_page);
    
    }
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    
    

    MainWindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QStandardItemModel>
    #include <QListView>
    #include <QStandardPaths>
    #include <QDebug>
    #include <QtSql/QSqlDatabase>
    #include <QtSql/QSqlQuery>
    #include <QFile>
    #include <QScrollArea>
    #include <QScroller>
    #include <QScreen>
    #include <QVBoxLayout>
    #include <QLabel>
    #include <QScrollerProperties>
    
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class MainWindow; }
    QT_END_NAMESPACE
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    #endif // MAINWINDOW_H
    
    

    Thanks in advance for the help.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved