aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorLeena Miettinen <riitta-leena.miettinen@qt.io>2020-09-29 14:28:27 +0200
committerLeena Miettinen <riitta-leena.miettinen@qt.io>2020-09-29 12:33:30 +0000
commit168c3df4c652c6dba58a635c90e93e4ec371d91c (patch)
tree3cfb70f68b7938010f09d3ad7a9c0510610a9c75 /doc
parent67bc45ebcd221dfc3da8a589d2a84cc6b0c13cb4 (diff)
Doc: Add missing file
This content was moved to a new file, but the file was not submitted as a part of the change. Change-Id: I44246688f5d8b0baf83069475fbd3c0a5c9a4c7d Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'doc')
-rw-r--r--doc/qtcreator/src/qtquick/qtquick-placeholder-data.qdoc123
1 files changed, 123 insertions, 0 deletions
diff --git a/doc/qtcreator/src/qtquick/qtquick-placeholder-data.qdoc b/doc/qtcreator/src/qtquick/qtquick-placeholder-data.qdoc
new file mode 100644
index 0000000000..b620a6e57b
--- /dev/null
+++ b/doc/qtcreator/src/qtquick/qtquick-placeholder-data.qdoc
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Creator documentation.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+**
+****************************************************************************/
+
+/*!
+ \page qtquick-placeholder-data.html
+ \if defined(qtdesignstudio)
+ \previouspage studio-simulation-overview.html
+ \nextpage studio-javascript.html
+ \else
+ \previouspage qtquick-annotations.html
+ \nextpage creator-quick-ui-forms.html
+ \endif
+
+ \title Loading Placeholder Data
+
+ The Design mode supports views, models, and delegates, so that when you add
+ a Grid View, List View, or Path View item, the ListModel and the delegate
+ item are added automatically.
+
+ However, the missing context of the application presents a challenge.
+ Specific models defined in C++ are the most obvious case. Often,
+ the context is missing simple properties, which are either defined in C++,
+ or in other QML files. A typical example is an item that uses the
+ properties of its parent, such as \c parent.width.
+
+ \section1 Using Dummy Models
+
+ If you open a file in the Design mode that references a C++ model, you see
+ nothing on the canvas. If the data in the model is fetched from the
+ internet, you have no control over it. To get reliable data, \e {dummy data}
+ was introduced.
+
+ For example, the following code snippet describes the file example.qml that
+ contains a ListView that in turn specifies a C++ model:
+
+ \qml
+ ListView {
+ model: dataModel
+ delegate: ContactDelegate {
+ name: name
+ }
+ }
+ \endqml
+
+ Create a directory named \e dummydata in the root directory of the project,
+ so that it is not deployed to the device. In the \c dummydata directory,
+ create a QML file that has the same name as the value of \c model:
+
+ \code
+ qml/exampleapp/example.qml
+ dummydata/dataModel.qml
+ \endcode
+
+ Then create the dataModel.qml file that contains the dummy data:
+
+ \qml
+ import QtQuick 2.0
+
+ ListModel {
+ ListElement {
+ name: "Ariane"
+ }
+ ListElement {
+ name: "Bella"
+ }
+ ListElement {
+ name: "Corinna"
+ }
+ }
+ \endqml
+
+ \section1 Creating Dummy Context
+
+ The following example presents a common pattern in QML:
+
+ \qml
+ Item {
+ width: parent.width
+ height: parent.height
+ }
+ \endqml
+
+ This works nicely for applications but the Design mode displays a zero-sized
+ item. A parent for the opened file does not exist, because the context is
+ missing. To get around the missing context, the idea of a \e {dummy
+ context} is introduced. If you place a file with the same name as the
+ application (here, example.qml) in the \c {dummydata/context} directory,
+ you can fake a parent context:
+
+ \qml
+ import QtQuick 2.0
+ import QmlDesigner 1.0
+
+ DummyContextObject {
+ parent: Item {
+ width: 640
+ height: 300
+ }
+ }
+ \endqml
+*/