summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2023-05-08 13:00:54 +0200
committerSamuel Gaist <samuel.gaist@idiap.ch>2023-10-14 20:19:56 +0000
commitc7eac23d9606ab145a4390a6e5446d0013d87d4b (patch)
treebad2770e8dffdc37a29e015db6f0918f47606599 /src/corelib/doc
parent33732478733dd7c5db4abd2daaab8e72661ae4c5 (diff)
doc: improve property example slot
The current example shows a minimal implementation. However, neither this example nor the documentation explains what happens without the guard. Although it's not mandatory, the large majority of the time it's a good practice to have it. This patch improves this part. Change-Id: I411a9d66bd7d8ba16aac87e28b5cab219fd71a5d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp3
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc5
2 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
index bb369e6456..4019fee583 100644
--- a/src/corelib/doc/snippets/code/doc_src_properties.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -68,6 +68,9 @@ public:
void setPriority(Priority priority)
{
+ if (m_priority == priority)
+ return;
+
m_priority = priority;
emit priorityChanged(priority);
}
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index 93624574d8..a05c21120c 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -208,7 +208,10 @@
The \c READ function is const and returns the property type. The
\c WRITE function returns void and has exactly one parameter of
the property type. The meta-object compiler enforces these
- requirements.
+ requirements. The equality check in the \c WRITE function, while not
+ mandatory, is good practice as there is no point in notifying and
+ potentially forcing re-evaluation in other places if nothing has
+ changed.
Given a pointer to an instance of MyClass or a pointer to a
QObject that is an instance of MyClass, we have two ways to set