diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-07-01 02:11:15 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-07-01 06:55:41 (GMT) |
commit | 0e7f70bb44eae2798c7f2198b713dc1c6ab6f652 (patch) | |
tree | ded37a0e5f614d751460e0e62319667c1ea247ae /examples/declarative | |
parent | 7cc5171a7d66390688444d57bb3f4550dbbd26ee (diff) | |
download | Qt-0e7f70bb44eae2798c7f2198b713dc1c6ab6f652.zip Qt-0e7f70bb44eae2798c7f2198b713dc1c6ab6f652.tar.gz Qt-0e7f70bb44eae2798c7f2198b713dc1c6ab6f652.tar.bz2 |
docs - quote code with snippets, other improvements
Diffstat (limited to 'examples/declarative')
5 files changed, 31 insertions, 21 deletions
diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h index c61e50c..17aa355 100644 --- a/examples/declarative/modelviews/objectlistmodel/dataobject.h +++ b/examples/declarative/modelviews/objectlistmodel/dataobject.h @@ -43,12 +43,14 @@ #include <QObject> +//![0] class DataObject : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) +//![0] public: DataObject(QObject *parent=0); @@ -67,6 +69,8 @@ signals: private: QString m_name; QString m_color; +//![1] }; +//![1] #endif // DATAOBJECT_H diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp index 25de8d1..8c921b7 100644 --- a/examples/declarative/modelviews/objectlistmodel/main.cpp +++ b/examples/declarative/modelviews/objectlistmodel/main.cpp @@ -53,24 +53,29 @@ model in QML */ +//![0] int main(int argc, char ** argv) { +//![0] QApplication app(argc, argv); - QDeclarativeView view; - +//![1] QList<QObject*> dataList; dataList.append(new DataObject("Item 1", "red")); dataList.append(new DataObject("Item 2", "green")); dataList.append(new DataObject("Item 3", "blue")); dataList.append(new DataObject("Item 4", "yellow")); + QDeclarativeView view; QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); view.setSource(QUrl("qrc:view.qml")); view.show(); +//![1] return app.exec(); +//![2] } +//![2] diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml index 034121c..c3cccdd 100644 --- a/examples/declarative/modelviews/objectlistmodel/view.qml +++ b/examples/declarative/modelviews/objectlistmodel/view.qml @@ -40,17 +40,17 @@ import Qt 4.7 +//![0] ListView { - width: 100 - height: 100 + width: 100; height: 100 anchors.fill: parent + model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } + delegate: Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } } } +//![0] diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp index b2ebd4b..ea73859 100644 --- a/examples/declarative/modelviews/stringlistmodel/main.cpp +++ b/examples/declarative/modelviews/stringlistmodel/main.cpp @@ -56,19 +56,20 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QDeclarativeView view; - +//![0] QStringList dataList; dataList.append("Item 1"); dataList.append("Item 2"); dataList.append("Item 3"); dataList.append("Item 4"); + QDeclarativeView view; QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); view.setSource(QUrl("qrc:view.qml")); view.show(); +//![0] return app.exec(); } diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml index ec5597d..3d789fd 100644 --- a/examples/declarative/modelviews/stringlistmodel/view.qml +++ b/examples/declarative/modelviews/stringlistmodel/view.qml @@ -39,17 +39,17 @@ ****************************************************************************/ import Qt 4.7 +//![0] ListView { - width: 100 - height: 100 + width: 100; height: 100 anchors.fill: parent + model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } + delegate: Rectangle { + height: 25 + width: 100 + Text { text: modelData } } } +//![0] |