[Qt-creator] Question about "Fetch data dynamically" option in new file wizard
Sean.Murphy at centauricorp.com
Wed May 12 15:58:53 CEST 2021
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
More information about the Qt-creator