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