Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
visual.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3/*!
4\page qtquick-usecase-visual.html
5\meta {keywords} {qmltopic}
6\title Visual types
7\keyword Use Case - Visual Elements In QML
8\brief Example of how to display visual item types in a QML application
9
10\section1 The Rectangle type
11
12For the most basic of visuals, \l {Qt Quick} provides a \l Rectangle type to
13draw rectangles. These rectangles can be colored with a color or a vertical
14gradient. The \l Rectangle type can also draw borders on the rectangle.
15
16For drawing custom shapes beyond rectangles, see the \l Canvas type or display
17a pre-rendered image using the \l Image type.
18
19\snippet qmlapp/usecases/visual-rects.qml 0
20\image qmlapp/qml-uses-visual-rectangles.png
21 {Square and rounded rectangle with gradient fill}
22
23\section1 The Image type
24
25\l {Qt Quick} provides an \l Image type which may be used to display images.
26The \l Image type has a \l {Image::}{source} property whose value can be a
27remote or local URL, or the URL of an image file embedded in a compiled
28resource file.
29
30\snippet qmlapp/usecases/visual.qml image
31
32For more complex images there are other types similar to \l Image.
33\l BorderImage draws an image with grid scaling, suitable for images used as
34borders. \l AnimatedImage plays animated .gif and .mng images. \l AnimatedSprite
35and \l SpriteSequence play animations comprised of multiple frames stored
36adjacently in a non-animated image format.
37
38For displaying video files and camera data, see the
39\l {qtmultimedia-index.html}{Qt Multimedia} module.
40
41\section1 Shared Visual Properties
42
43All visual items provided by \l {Qt Quick} are based on the Item type, which
44provides a common set of attributes for visual items, including opacity and
45transform attributes.
46
47\section2 Opacity and Visibility
48
49The QML object types provided by Qt Quick have built-in support for
50\l{Item::opacity}{opacity}. Opacity can be animated to allow smooth transitions
51to or from a transparent state. Visibility can also be managed with the
52\l{Item::visible}{visible} property more efficiently, but at the cost of not
53being able to animate it.
54
55\snippet qmlapp/usecases/visual-opacity.qml 0
56\image qmlapp/qml-uses-visual-opacity.png
57 {Red and blue overlapping squares demonstrating opacity blending}
58
59\section2 Transforms
60
61Qt Quick types have built-in support for transformations. If you wish to have
62your visual content rotated or scaled, you can set the \l Item::rotation or
63\l Item::scale property. These can also be animated.
64
65\snippet qmlapp/usecases/visual-transforms.qml 0
66\image qmlapp/qml-uses-visual-transforms.png
67 {Blue square rotated 45 degrees and smaller green square}
68
69For more complex transformations, see the \l Item::transform property.
70
71*/