From 46b8f2eb1a2ef9655c963b567a517352facd307c Mon Sep 17 00:00:00 2001 From: Oleksii Zbykovskyi Date: Tue, 19 Aug 2025 10:05:29 +0200 Subject: 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 --- src/widgets/doc/snippets/sharedtablemodel/main.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'src/widgets/doc/snippets/sharedtablemodel/main.cpp') 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 #include -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[]) { -- cgit v1.2.3