diff options
| author | Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> | 2025-08-19 10:05:29 +0200 |
|---|---|---|
| committer | Oleksii Zbykovskyi <Oleksii.Zbykovskyi@qt.io> | 2025-08-20 20:15:46 +0200 |
| commit | 46b8f2eb1a2ef9655c963b567a517352facd307c (patch) | |
| tree | d309756adb33a30e4bc17a02b796786b32476e59 /src/widgets/doc/snippets/sharedtablemodel | |
| parent | ae6f389942d60959fcae0f5d9f2bb6eadd8efb06 (diff) | |
Widgets snippets: Use the header file instead of a new class each time
In several snippets, the TableModel class is created and used.
I included a header file to avoid code repetition.
Change-Id: Ie6318606cc89a2f5f1c137a36195fe290b6c1be6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/doc/snippets/sharedtablemodel')
| -rw-r--r-- | src/widgets/doc/snippets/sharedtablemodel/main.cpp | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/widgets/doc/snippets/sharedtablemodel/main.cpp b/src/widgets/doc/snippets/sharedtablemodel/main.cpp index ab02094595d..76a4ebc6670 100644 --- a/src/widgets/doc/snippets/sharedtablemodel/main.cpp +++ b/src/widgets/doc/snippets/sharedtablemodel/main.cpp @@ -13,25 +13,7 @@ #include <QItemSelectionModel> #include <QTableView> -class TableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - TableModel(int rows, int columns, QObject *parent = nullptr) - : QAbstractTableModel(parent), rowCount(rows), columnCount(columns) {} - - int rowCount(const QModelIndex &parent = QModelIndex()) const override { - return rowCount; - } - - int columnCount(const QModelIndex &parent = QModelIndex()) const override { - return columnCount; - } - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { - return QVariant(); - } -}; +#include "../common-table-model/model.h" int main(int argc, char *argv[]) { |
