summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_properties.qdoc
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-11-08 20:48:52 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-11-22 09:21:03 (GMT)
commit1ab855cd61581a073da86d2c64be0b889f004327 (patch)
treec9a91efc8b8187c4a12f473cc1ae20216f473be5 /doc/src/snippets/code/doc_src_properties.qdoc
parentbafdb949583a3178449f68afe2e2621687e29de7 (diff)
downloadQt-1ab855cd61581a073da86d2c64be0b889f004327.zip
Qt-1ab855cd61581a073da86d2c64be0b889f004327.tar.gz
Qt-1ab855cd61581a073da86d2c64be0b889f004327.tar.bz2
Doc: Q_PROPERTY, implements the setter/getter in the example
Some developer thought the implementation of the getters and setters needed to have some metaobject magic Also add a NOTIFY signal in the example Reviewed-by: Joao
Diffstat (limited to 'doc/src/snippets/code/doc_src_properties.qdoc')
-rw-r--r--doc/src/snippets/code/doc_src_properties.qdoc17
1 files changed, 14 insertions, 3 deletions
diff --git a/doc/src/snippets/code/doc_src_properties.qdoc b/doc/src/snippets/code/doc_src_properties.qdoc
index 7704160..a4ed409 100644
--- a/doc/src/snippets/code/doc_src_properties.qdoc
+++ b/doc/src/snippets/code/doc_src_properties.qdoc
@@ -91,7 +91,7 @@ for (int i=0; i<count; ++i) {
class MyClass : public QObject
{
Q_OBJECT
- Q_PROPERTY(Priority priority READ priority WRITE setPriority)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
Q_ENUMS(Priority)
public:
@@ -100,8 +100,19 @@ public:
enum Priority { High, Low, VeryHigh, VeryLow };
- void setPriority(Priority priority);
- Priority priority() const;
+ void setPriority(Priority priority)
+ {
+ m_priority = priority;
+ emit priorityChanged(priority);
+ }
+ Priority priority() const
+ { return m_priority; }
+
+signals:
+ void priorityChanged(Priority);
+
+private:
+ Priority m_priority;
};
//! [5]