From 67086b4149da86427666967d11f3c0f33330b5b3 Mon Sep 17 00:00:00 2001 From: Oleksii Zbykovskyi Date: Tue, 5 Aug 2025 10:01:40 +0200 Subject: Make snippets in widget folder compilable and add to the build system Created a CMakeLists.txt file in the widgets folder and added snippets to it. Fixed related issues with missing includes and compilation errors. Task-number: QTBUG-137566 Change-Id: Ief61c3675d8b4d5935bbb0cb951d3a9e82f437f7 Reviewed-by: Volker Hilsheimer --- src/widgets/doc/snippets/sharedtablemodel/main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (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 d9bc7bdd5a1..5789dadaec4 100644 --- a/src/widgets/doc/snippets/sharedtablemodel/main.cpp +++ b/src/widgets/doc/snippets/sharedtablemodel/main.cpp @@ -13,7 +13,25 @@ #include #include -#include "model.h" +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(); + } +}; int main(int argc, char *argv[]) { -- cgit v1.2.3