1 /****************************************************************************
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
6 ** This file is part of the documentation of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
17 ** GNU Free Documentation License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Free
19 ** Documentation License version 1.3 as published by the Free Software
20 ** Foundation and appearing in the file included in the packaging of
21 ** this file. Please review the following information to ensure
22 ** the GNU Free Documentation License version 1.3 requirements
23 ** will be met: http://www.gnu.org/copyleft/fdl.html.
26 ****************************************************************************/
29 \title Animation: Basics Example
30 \example declarative/animation/basics/color-animation
31 \depends helper/qmlapplicationviewer
33 \brief This example shows how to create and combine \l{QML Animation}{animations} in QML.
37 \o \image qml-coloranim-example.png
39 \o color-animation.qml
44 \title Animation: Basics Property Animation Example
45 \example declarative/animation/basics/property-animation
46 \depends helper/qmlapplicationviewer
48 \brief This example shows how to create and combine \l{QML Animation}{animations} in QML.
52 \o \image qml-propertyanim-example.png
54 \o property-animation.qml
59 \title Animation: Behavior Example
60 \example declarative/animation/behaviors/behavior-example
61 \depends helper/qmlapplicationviewer
63 \brief This example shows how to use QML behaviors.
65 \image qml-behaviors-example.png
69 \title Animation: Wiggly Text Example
70 \example declarative/animation/behaviors/wigglytext
71 \depends helper/qmlapplicationviewer
73 \brief This example shows how to animate text.
78 \title Animation: Easing Example
79 \example declarative/animation/easing
80 \depends helper/qmlapplicationviewer
82 \brief This example shows the different easing modes available for \l{QML Animation}{animations}.
84 \image qml-easing-example.png
88 \title Animation: States Example
89 \example declarative/animation/states
91 \brief These examples show how to use states and transitions.
93 \depends helper/qmlapplicationviewer
95 The \c states.qml example shows how an item can change between states, and \c transitions.qml
96 shows how these state changes can be animated.
98 \note Due to deployment configurations transitions.qml is opened by default when running this example.
99 states.qml can be opened by editing the main.cpp file.
103 \o \image qml-states-example.png
110 \o \image qml-transitions-example.png
117 \title Image Elements: Border Image Example
118 \example declarative/imageelements/borderimage
120 \brief These examples show how to use the BorderImage element.
122 \depends helper/qmlapplicationviewer
126 \o \image qml-borderimage-example.png
133 \title Image Elements: Shadows Image Example
134 \example declarative/imageelements/shadows
135 \depends helper/qmlapplicationviewer
137 \brief This example shows how to use the BorderImage element.
141 \o \image qml-borderimage-shadows-example.png
148 \title Image Elements: Image Example
149 \example declarative/imageelements/image
150 \depends helper/qmlapplicationviewer
152 \brief This example shows how to use the \l Image element and its \l{Image::fillMode}{fillModes}.
155 \image qml-image-example.png
159 \page declarative-cppextensions-reference.html
160 \title C++ Extensions: Reference examples
162 \brief These examples show how QML can be extended from C++ in various ways.
164 The code for these examples is used throughout the \l {Extending QML Functionalities using C++} reference
165 documentation, which highlights the main principles demonstrated in each example.
167 Furthermore, here are additional pages that discuss each example in detail:
170 \o \l {declarative/cppextensions/referenceexamples/adding}{Adding Types}
171 \o \l {declarative/cppextensions/referenceexamples/properties}{Object and List Property Types}
172 \o \l {declarative/cppextensions/referenceexamples/coercion}{Inheritance and Coercion}
173 \o \l {declarative/cppextensions/referenceexamples/default}{Default Property}
174 \o \l {declarative/cppextensions/referenceexamples/grouped}{Grouped Properties}
175 \o \l {declarative/cppextensions/referenceexamples/attached}{Attached Properties}
176 \o \l {declarative/cppextensions/referenceexamples/signal}{Signal Support}
177 \o \l {declarative/cppextensions/referenceexamples/methods}{Methods Support}
178 \o \l {declarative/cppextensions/referenceexamples/valuesource}{Property Value Source}
179 \o \l {declarative/cppextensions/referenceexamples/binding}{Binding}
182 \note These examples all print information to the console to demonstrate the concepts presented.
183 Ensure that you are able to view the application output when running these examples.
184 For example, the dbgView tool on Windows can be used to display application output.
188 \title C++ Extensions: Plugins Example
189 \example declarative/cppextensions/plugins
191 \brief This example shows how to create a C++ plugin extension by subclassing QDeclarativeExtensionPlugin.
193 \image qml-plugins-example.png
197 \title LayoutItem Example
198 \example declarative/cppextensions/qgraphicslayouts/layoutitem
200 \brief This example show how to use the LayoutItem element to integrate QML items into an existing
201 \l{Graphics View Framework}{Graphics View}-based application.
203 \image qml-layoutitem-example.png
206 \title QGraphicsGridLayout Example
207 \example declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout
209 \brief This example shows how to use QGraphicsGridLayout to lay out QML items. This is
210 useful if you need to integrate Qt \l{Graphics View Framework}{Graphics View} layouts with
213 \image qml-qgraphicsgridlayout-example.png
216 \title QGraphicsLinearLayout Example
217 \example declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout
219 \brief This example shows how to use QGraphicsLinearLayout to lay out QML items. This is
220 useful if you need to integrate Qt \l{Graphics View Framework}{Graphics View} layouts with
223 \image qml-qgraphicslinearlayout-example.png
226 \title C++ Extensions: QGraphicsLayouts examples
227 \page declarative-cppextensions-qgraphicslayouts.html
229 \brief These examples show how to integrate \l{Graphics View Framework}{Graphics View}
230 layout components with QML:
233 \o \l{declarative/cppextensions/qgraphicslayouts/layoutitem}{LayoutItem}
234 \o \l{declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout}{QGraphicsGridLayout}
235 \o \l{declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout}{QGraphicsLinearLayout}
238 Also see \l {Integrating QML Code with Existing Qt UI Code} for information on using QML
239 in Qt applications that use the Graphics View framework or ordinary QWidget-based views.
243 \title C++ Extensions: QWidgets Example
244 \example declarative/cppextensions/qwidgets
246 \brief This example shows how to embed QWidget-based objects into QML using QGraphicsProxyWidget.
248 \image qml-qwidgets-example.png
252 \title C++ Extensions: Image Provider Example
253 \example declarative/cppextensions/imageprovider
255 \brief This examples shows how to use QDeclarativeImageProvider to serve images
256 to QML image elements.
258 \image qml-imageprovider-example.png
262 \title C++ Extensions: Network Access Manager Factory Example
263 \example declarative/cppextensions/networkaccessmanagerfactory
265 \brief This example shows how to use QDeclarativeNetworkAccessManagerFactory to create a QNetworkAccessManager
270 \title Internationalization Example
271 \example declarative/i18n
272 \ingroup internationalization
273 \depends helper/qmlapplicationviewer
275 \brief This example shows how to enable text translation in QML.
277 \image qml-i18n-example.png
279 \section1 Introduction
281 The QML runtime automatically loads a translation from the i18n subdirectory
282 of the root QML file, based on the system language. The translations are
283 held in QM files that must be generated from TS files.
285 \section1 Updating Translations
287 The \c{.ts} files are created and updated by running:
290 lupdate i18n.qml -ts i18n/base.ts
293 If no translation file exists, one will be created. If a file already exists,
294 it will be updated to contain the latest strings from the QML file.
296 Translations for new languages are created by copying \c{i18n/base.ts} to
297 \c{i18n/qml_<lang>.ts} The TS files can then be edited with
298 \l{Qt Linguist Manual}{Qt Linguist}:
301 linguist i18n/qml_fr.ts
304 The run-time translation files are then generated by running:
312 \title Right-to-left User Interfaces: Text Alignment Example
313 \example declarative/righttoleft/textalignment
314 \depends helper/qmlapplicationviewer
316 \brief This example shows how the horizontal alignment of \l Text,
317 \l TextInput and \l TextEdit is affected by the reading direction
318 of the text and by the layout mirrroring.
320 Click on the gray buttons
321 shown at the bottom of the example to toggle between different
322 horizontal alignment options.
324 \sa {QML Right-to-left User Interfaces}
328 \title Right-to-left User Interfaces: Layout Direction Example
329 \example declarative/righttoleft/layoutdirection
330 \depends helper/qmlapplicationviewer
332 \ brief This example shows how to control the horizontal layout direction of
333 \l Row, \l Grid and \l Flow positioners, and \l ListView and \l GridView
336 Click on the gray buttons shown at the bottom of the example
337 to toggle the layout direction of the shown elements.
339 \image qml-righttoleft-layoutdirection-example.png
341 \sa {QML Right-to-left User Interfaces}
346 \title Right-to-left User Interfaces: Layout Mirroring Example
347 \example declarative/righttoleft/layoutmirroring
348 \depends helper/qmlapplicationviewer
350 \brief This example shows how to mirror the application layouts
351 using \l LayoutMirroring attached property.
353 Click on the grey button shown at the bottom of the example to
354 enable or disable the layout mirroring.
356 \image qml-righttoleft-layoutmirroring-example.png
358 \sa {QML Right-to-left User Interfaces}
362 \title Positioners Example
363 \example declarative/positioners
364 \depends helper/qmlapplicationviewer
366 \brief This example shows how to use positioner elements such as \l Row, \l Column,
369 \image qml-positioners-example.png
373 \title Key Interaction: Focus Example
374 \example declarative/keyinteraction/focus
375 \depends helper/qmlapplicationviewer
377 \brief This example shows how to handle keyboard input and focus in QML.
379 \image qml-focus-example.png
383 \title Models and Views: AbstractItemModel Example
384 \example declarative/modelviews/abstractitemmodel
385 \depends helper/qmlapplicationviewer
387 \brief This example shows how to use a QAbstractItemModel subclass as a model in QML.
389 \image qml-abstractitemmodel-example.png
393 \title Models and Views: GridView Example
394 \example declarative/modelviews/gridview
395 \depends helper/qmlapplicationviewer
397 \brief This example shows how to use the GridView element.
399 \image qml-gridview-example.png
403 \title Models and Views: ListView Examples
404 \page qml-listview-examples.html
407 \o \l {Models and Views: Dynamic List ListView Example}
408 \o \l {Models and Views: Expanding Delegate ListView Example}
409 \o \l {Models and Views: Highlight ListView Example}
410 \o \l {Models and Views: Highlight Ranges ListView Example}
411 \o \l {Models and Views: Sections ListView Example}
417 \title Models and Views: Dynamic List ListView Example
418 \example declarative/modelviews/listview/dynamiclist
419 \depends helper/qmlapplicationviewer
421 \brief This example shows how items can be dynamically added to
422 and removed from a ListModel, and how these list
423 modifications can be animated.
427 \o \image qml-listview-dynamiclist-example.png
434 \title Models and Views: Expanding Delegate ListView Example
435 \example declarative/modelviews/listview/expandingdelegates
436 \depends helper/qmlapplicationviewer
438 \brief This example shows how to create a dynamic delegate, which
439 expands when selected.
443 \o \image qml-listview-expandingdelegates-example.png
445 \o expandingdelegates.qml
450 \title Models and Views: Highlight ListView Example
451 \example declarative/modelviews/listview/highlight
452 \depends helper/qmlapplicationviewer
455 \brief This example shows how to highlight one item
456 inside a ListView element.
460 \o \image qml-listview-highlight-example.png
467 \title Models and Views: Highlight Ranges ListView Example
468 \example declarative/modelviews/listview/highlightranges
469 \depends helper/qmlapplicationviewer
472 \brief This example shows how to highlight ranges within a
477 \o \image qml-listview-highlightranges-example.png
479 \o highlightranges.qml
484 \title Models and Views: Sections ListView Example
485 \example declarative/modelviews/listview/sections
486 \depends helper/qmlapplicationviewer
489 \brief This example shows how to use the ListView element.
493 \o \image qml-listview-sections-example.png
500 \title Models and Views: PathView Example
501 \example declarative/modelviews/pathview
502 \depends helper/qmlapplicationviewer
504 \brief This example shows how to use the PathView element.
506 \image qml-pathview-example.png
510 \title Models and Views: Object ListModel Example
511 \example declarative/modelviews/objectlistmodel
512 \depends helper/qmlapplicationviewer
514 \brief This example shows how to use a QList<QObject*> as a model in QML.
516 \image qml-objectlistmodel-example.png
520 \title Models and Views: Package Example
521 \example declarative/modelviews/package
522 \depends helper/qmlapplicationviewer
524 \brief This example shows how to use the \l Package element.
526 \image qml-package-example.png
530 \title Models and Views: Parallax Example
531 \example declarative/modelviews/parallax
532 \depends helper/qmlapplicationviewer
534 \brief This example shows how to combine and switch between views.
536 \image qml-parallax-example.png
540 \title Models and Views: String ListModel Example
541 \example declarative/modelviews/stringlistmodel
542 \depends helper/qmlapplicationviewer
544 \brief This example shows how to use a QStringList as a model in QML.
546 \image qml-stringlistmodel-example.png
550 \title Models and Views: VisualItemModel Example
551 \example declarative/modelviews/visualitemmodel
552 \depends helper/qmlapplicationviewer
554 \brief This example shows how to use the VisualItemModel element.
556 \image qml-visualitemmodel-example.png
560 \title Models and Views: WebView Examples
561 \page qml-webview-examples.html
563 \brief These examples show how to use the WebView element.
566 \o \l {Models and Views: Alert WebView Example}
567 \o \l {Models and Views: Autosize WebView Example}
568 \o \l {Models and Views: GoogleMaps WebView Example}
569 \o \l {Models and Views: Inline HTML WebView Example}
570 \o \l {Models and Views: New Windows WebView Example}
576 \title Models and Views: Alert WebView Example
577 \example declarative/modelviews/webview/alerts
578 \depends helper/qmlapplicationviewer
580 \brief This example shows how to create an alert in the WebView element.
584 \o \image qml-webview-alert-example.png
591 \title Models and Views: Autosize WebView Example
592 \example declarative/modelviews/webview/autosize
593 \depends helper/qmlapplicationviewer
595 \brief This example show how to use autosizing in the WebView element.
599 \o \image qml-webview-autosize-example.png
606 \title Models and Views: GoogleMaps WebView Example
607 \example declarative/modelviews/webview/googlemaps
608 \depends helper/qmlapplicationviewer
610 \brief This example shows how to use a web service API and the WebView element.
614 \o \image qml-webview-googlemaps-example.png
621 \title Models and Views: Inline HTML WebView Example
622 \example declarative/modelviews/webview/inlinehtml
623 \depends helper/qmlapplicationviewer
625 \brief This example shows how to use inline HTML with the WebView element.
629 \o \image qml-webview-inlinehtml-example.png
636 \title Models and Views: New Windows WebView Example
637 \example declarative/modelviews/webview/newwindows
638 \depends helper/qmlapplicationviewer
640 \brief These examples show how to create new windows in the WebView element.
644 \o \image qml-webview-newwindows-example.png
651 \title Screen Orientation
652 \example declarative/screenorientation
653 \depends helper/qmlapplicationviewer
655 \brief This example shows how to implement screen orientation support for your application.
659 \title SQL Local Storage Example
660 \example declarative/sqllocalstorage
661 \depends helper/qmlapplicationviewer
663 \brief This example shows how to use the SQL Local Storage API in QML.
667 \title Text: Fonts Example
668 \example declarative/text/fonts
669 \depends helper/qmlapplicationviewer
671 \brief These examples show how to discover available fonts from QML.
675 \o \image qml-fonts-availableFonts-example.png
677 \o availableFonts.qml
682 \title Text: Banner Fonts Example
683 \example declarative/text/fonts/banner
684 \depends helper/qmlapplicationviewer
686 \brief These example shows how to manipulate text in various ways.
690 \o \image qml-fonts-banner-example.png
697 \title Text: Fonts Example
698 \example declarative/text/fonts/fonts
699 \depends helper/qmlapplicationviewer
701 \brief These examples shows how to display a text with multiple fonts.
705 \o \image qml-fonts-fonts-example.png
712 \title Text: Hello Fonts Example
713 \example declarative/text/fonts/hello
714 \depends helper/qmlapplicationviewer
716 \brief This example shows how to manipulate text in various ways.
720 \o \image qml-fonts-hello-example.png
727 \title Text: Text Selection Example
728 \example declarative/text/textselection
729 \depends helper/qmlapplicationviewer
731 \brief This example shows how text selection, copy and paste operations
732 can be implemented on top of the TextEdit element.
734 \image qml-textselection-example.png
738 \title Threading: Threaded ListModel Example
739 \example declarative/threading/threadedlistmodel
740 \depends helper/qmlapplicationviewer
742 \brief This example shows how to use a ListModel from multiple threads using
747 \title Threading: WorkerScript Example
748 \example declarative/threading/workerscript
749 \depends helper/qmlapplicationviewer
751 \brief This example shows how to use the WorkerScript element for threading in QML.
755 \title Toys: Clocks Example
756 \example declarative/toys/clocks
757 \depends helper/qmlapplicationviewer
759 \brief This example displays a set of clocks with different times for different cities.
761 Each clock is created by combining \l Image elements with \l Rotation transforms
762 and \l SpringAnimation behaviors.
764 \image qml-clocks-example.png
768 \title Toys: Corkboards Example
769 \example declarative/toys/corkboards
770 \depends helper/qmlapplicationviewer
772 \brief This example presents a flickable set of interactive corkboards. It is created
773 through a combination of elements like \l ListModel, \l Repeater and \l TextEdit
774 together with rotation and scaling transforms, animation and mouse interaction.
776 \image qml-corkboards-example.png
780 \title Toys: Dynamic Scene Example
781 \example declarative/toys/dynamicscene
782 \depends helper/qmlapplicationviewer
784 \brief This example presents an interactive drag-and-drop scene. It demonstrates
785 how to use QML's \l{Dynamic Object Creation} support to dynamically create and
788 \image qml-dynamicscene-example.png
792 \title Toys: Tic-Tac-Toe Example
793 \example declarative/toys/tic-tac-toe
794 \depends helper/qmlapplicationviewer
796 \brief This example presents a simple implementation of Tic Tac Toe.
798 \image qml-tic-tac-toe-example.png
802 \title Toys: TV Tennis Example
803 \example declarative/toys/tvtennis
804 \depends helper/qmlapplicationviewer
806 \brief This example shows how to use animation components such as \l SpringAnimation,
807 \l SequentialAnimation and \l PropertyAction to create a game of TV tennis.
809 \image qml-tvtennis-example.png
813 \title Touch Interaction: Gestures Example
814 \example declarative/touchinteraction/gestures
815 \depends helper/qmlapplicationviewer
817 \brief This example shows how to use the GestureArea element.
821 \title Touch Interaction: MouseArea Example
822 \example declarative/touchinteraction/mousearea
823 \depends helper/qmlapplicationviewer
825 \brief This example shows how to use the MouseArea element to access information
828 \image qml-mousearea-example.png
832 \title UI Components: Dial Control Example
833 \example declarative/ui-components/dialcontrol
834 \depends helper/qmlapplicationviewer
836 \brief This example shows how to create a dial-type control. It combines
837 \l Image elements with \l Rotation transforms and \l SpringAnimation behaviors
838 to produce an interactive speedometer-type dial.
840 \image qml-dialcontrol-example.png
845 \title UI Components: Flipable Example
846 \example declarative/ui-components/flipable
847 \depends helper/qmlapplicationviewer
849 \brief This example shows how to use the \l Flipable element.
851 \image qml-flipable-example.png
855 \title UI Components: Progress Bars Example
856 \example declarative/ui-components/progressbar
857 \depends helper/qmlapplicationviewer
859 \brief This example shows how to create a progress bar.
861 \image qml-progressbar-example.png
865 \title UI Components: Scroll Bar Example
866 \example declarative/ui-components/scrollbar
867 \depends helper/qmlapplicationviewer
869 \brief This example shows how to create scroll bars for a \l Flickable element
870 using the \l {Flickable::visibleArea.xPosition}{Flickable::visibleArea}
873 \image qml-scrollbar-example.png
877 \title UI Components: Search Box Example
878 \example declarative/ui-components/searchbox
879 \depends helper/qmlapplicationviewer
881 \brief This example shows how to combine TextInput, FocusScope and BorderImage
882 elements to display multiple text input fields.
884 \image qml-searchbox-example.png
888 \title UI Components: Slide Switch Example
889 \example declarative/ui-components/slideswitch
890 \depends helper/qmlapplicationviewer
892 \brief This example shows how to create a slide switch control.
894 \image qml-slideswitch-example.png
898 \title UI Components: Spinner Example
899 \example declarative/ui-components/spinner
900 \depends helper/qmlapplicationviewer
902 \brief This example shows how to create a spinner-type component using the PathView element.
904 \image qml-spinner-example.png
908 \title UI Components: Tab Widget Example
909 \example declarative/ui-components/tabwidget
910 \depends helper/qmlapplicationviewer
912 \brief This example shows how to create a tab widget. It also demonstrates how
913 \l {Property aliases}{property aliases} and
914 \l {Introduction to the QML Language#Default Properties}{default properties} can be used to collect and
915 assemble the child items declared within an \l Item.
917 \image qml-tabwidget-example.png
921 \title XML: XMLHttpRequest Example
922 \example declarative/xml/xmlhttprequest
923 \depends helper/qmlapplicationviewer
925 \brief This example shows how to use the \l XmlHttpRequest API in QML.
927 \image qml-xmlhttprequest-example.png
931 \title Labs: Shader Effects
932 \example declarative/shadereffects
933 \depends helper/qmlapplicationviewer
935 \brief This example shows how to create visual effects by using OpenGL shading language together with QML using \l ShaderEffectItem and \l ShaderEffectSource APIs.
937 \image qml-shadereffects-example.png