[Qt-creator] Question about "Fetch data dynamically" option in new file wizard

Christian Stenger Christian.Stenger at qt.io
Tue May 18 09:11:01 CEST 2021

seems like this is provided only for QAbstractItemModel based classes.. I'd say this is wrong and will be fixed.


From: Qt-creator <qt-creator-bounces at qt-project.org> on behalf of Murphy, Sean <Sean.Murphy at centauricorp.com>
Sent: Wednesday, May 12, 2021 3:58 PM
To: Qt-creator at qt-project.org
Subject: [Qt-creator] Question about "Fetch data dynamically" option in new     file wizard

I'm creating a model class for a large table, so I would like to use lazy loading.

1. In Qt Creator, I right-click my project and select the "Add New..." option.
2. In the new file creation wizard that pops up, I select the "Qt" option from
    the "Files and Classes" list, and then select the "Qt Item Model", then pressed
    the "Choose..." button.
3. On the next page, I enter my desired class name, select "QAbstractTableModel"
    as the base class and then ensure the "Customize header row" and
    "Fetch data dynamically" checkboxes are checked.
4. I then completed the remaining steps in the wizard.

In the resulting class's header file, I only ended up with these functions defined for me:
    explicit viewRawDataTableModel(QObject *parent = nullptr);
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

I kind of expected that in addition to those functions above, the process would have also added functions like:
  virtual bool canFetchMore(const QModelIndex &parent) const;
  virtual void fetchMore(const QModelIndex &parent);

Is this a bug, or am I just misunderstanding what that "Fetch data dynamically" checkbox
is supposed to do when generating a new class?

Qt Creator 4.14.2


Qt-creator mailing list
Qt-creator at qt-project.org

More information about the Qt-creator mailing list