summaryrefslogtreecommitdiffstats
path: root/examples/widgets/doc
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-11-16 08:43:08 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-12-04 07:38:56 +0100
commitd9c71b834ccd815b85e9589f21eba1f51c48614a (patch)
tree7e7ea7bfb741f57782c35796c107bb62219ebae5 /examples/widgets/doc
parent9590ed6ba6dfc565832acddb69c69a3c8bf5e2e6 (diff)
SimpleTreeModel: Add a test
Add a test running QAbstractItemModelTester on the model. Pick-to: 6.6 Change-Id: I6ea5d34308357409b9a13eb0271392c8d171addd Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Diffstat (limited to 'examples/widgets/doc')
-rw-r--r--examples/widgets/doc/src/simpletreemodel.qdoc16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/widgets/doc/src/simpletreemodel.qdoc b/examples/widgets/doc/src/simpletreemodel.qdoc
index 9e7e021700..55b4f139f0 100644
--- a/examples/widgets/doc/src/simpletreemodel.qdoc
+++ b/examples/widgets/doc/src/simpletreemodel.qdoc
@@ -318,4 +318,20 @@
To ensure that the model works correctly, it is only necessary to
create instances of \c TreeItem with the correct data and parent item.
+
+ \section1 Testing the model
+
+ Correctly implementing an item model can be challenging. The class
+ \l QAbstractItemModelTester from the \l{Qt Test} module checks for model
+ consistency, like the model index creation and parent-child relationships.
+
+ You can test your model by just passing a model instance to the class
+ constructor, for instance as part of a Qt unit test:
+
+ \snippet itemviews/simpletreemodel/test.cpp 1
+
+ To create a test which can be run using the \c ctest executable,
+ \c add_test() is used:
+
+ \snippet itemviews/simpletreemodel/CMakeLists.txt 1
*/