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\title Visual types
6\keyword Use Case - Visual Elements In QML
7\brief Example of how to display visual item types in a QML application
8
9\section1 The Rectangle type
10
11For the most basic of visuals, \l {Qt Quick} provides a \l Rectangle type to
12draw rectangles. These rectangles can be colored with a color or a vertical
13gradient. The \l Rectangle type can also draw borders on the rectangle.
14
15For drawing custom shapes beyond rectangles, see the \l Canvas type or display
16a pre-rendered image using the \l Image type.
17
18\snippet qmlapp/usecases/visual-rects.qml 0
19\image qmlapp/qml-uses-visual-rectangles.png
20
21\section1 The Image type
22
23\l {Qt Quick} provides an \l Image type which may be used to display images.
24The \l Image type has a \l {Image::}{source} property whose value can be a
25remote or local URL, or the URL of an image file embedded in a compiled
26resource file.
27
28\snippet qmlapp/usecases/visual.qml image
29
30For more complex images there are other types similar to \l Image.
31\l BorderImage draws an image with grid scaling, suitable for images used as
32borders. \l AnimatedImage plays animated .gif and .mng images. \l AnimatedSprite
33and \l SpriteSequence play animations comprised of multiple frames stored
34adjacently in a non-animated image format.
35
36For displaying video files and camera data, see the
37\l {qtmultimedia-index.html}{Qt Multimedia} module.
38
39\section1 Shared Visual Properties
40
41All visual items provided by \l {Qt Quick} are based on the Item type, which
42provides a common set of attributes for visual items, including opacity and
43transform attributes.
44
45\section2 Opacity and Visibility
46
47The QML object types provided by Qt Quick have built-in support for
48\l{Item::opacity}{opacity}. Opacity can be animated to allow smooth transitions
49to or from a transparent state. Visibility can also be managed with the
50\l{Item::visible}{visible} property more efficiently, but at the cost of not
51being able to animate it.
52
53\snippet qmlapp/usecases/visual-opacity.qml 0
54\image qmlapp/qml-uses-visual-opacity.png
55
56\section2 Transforms
57
58Qt Quick types have built-in support for transformations. If you wish to have
59your visual content rotated or scaled, you can set the \l Item::rotation or
60\l Item::scale property. These can also be animated.
61
62\snippet qmlapp/usecases/visual-transforms.qml 0
63\image qmlapp/qml-uses-visual-transforms.png
64
65For more complex transformations, see the \l Item::transform property.
66
67*/