summaryrefslogtreecommitdiffstats
path: root/doc/src/graphics.qdoc
blob: ce958b90678bca9837e1e7875661095faf5a802c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page topics-graphics.html
\title Graphics
\brief Qt's graphics features

Graphics in Qt 5 is primarily done either through the imperative QPainter API,
or through Qt’s declarative UI language, Qt Quick, and its scene graph back-end.
Qt 5's graphics capabilities also includes support for printing, as well as the
loading and saving of various image formats.



\section1 2D Graphics with QPainter

QPainter provides API for drawing vector graphics, text and images
onto different surfaces, or QPaintDevice instances, such as QImage,
QOpenGLPaintDevice, QWidget, and QPrinter. The actual drawing happens
in the QPaintDevice's QPaintEngine. The software rasterizer and the
OpenGL (ES) 2.0 back-ends are the two most important QPaintEngine
implementations. The raster paint engine is Qt’s software rasterizer,
and is used when drawing on a QImage or QWidget. Its strength over the
OpenGL paint engine is its high quality when antialiasing is enabled,
and a complete feature set.

\sa {Paint System}

\list

    \li \l {Paint System}{Paint System} - Overview over the QPainter
    classes and architecture.

    \li \l {Coordinate System}{Coordinate System} - Explains how
    QPainter's coordinate system works.

    \li \l {Drawing and Filling}{Drawing and Filling} - Explains how
    QPainter performs filling and outlining of vector shapes.

\endlist

The most important rendering targets for QPainter are:

\list

    \li \l {QImage}{QImage} - A hardware-independent image representation
    with direct pixel access. QPainter will use the software
    rasterizer to draw to QImage instances.

    \li \l {QPixmap}{QPixmap} - A image representation suited for display
    on screen. QPainter will primarily use the software rasterizer to
    draw to QPixmap instances.

    \li \l {QOpenGLPaintDevice}{QOpenGLPaintDevice} - A paint device to
    render to the current OpenGL (ES) 2.0 context. QPainter will use
    hardware accellerated OpenGL calls to draw to QOpenGLPaintDevice
    instances.

    \li \l {QBackingStore}{QBackingStore} - A backbuffer for top-level
    windows. QPainter will primarily use the software rasterizer to
    draw to QBackingStore instances.

    \li \l {QWidget}{QWidget} - A baseclass for pre-Qt Quick user
    interface classes. QPainter will render widgets using a
    QBackingStore.

    \li \l {QOpenGLWidget}{QOpenGLWidget} - A painter can also be
    opened on a QOpenGLWidget. This is provided as a convenience, since
    technically this is no different than using QOpenGLPaintDevice.

\endlist

QPainter and related classes are part of the \l {Qt GUI} module.



\section1 OpenGL and 3D

OpenGL is the most widely adopted graphics API for hardware accelerated and 3D graphics, implemented on all
desktop platforms and almost every mobile and embedded platform. The
Qt library contains a number of classes that help users integrate
OpenGL into their applications.

\list

    \li \l {qtgui-index.html#opengl-and-opengl-es-integration}{OpenGL
    in Qt GUI} - An overview of how OpenGL integrates with the \l{Qt GUI}
    module.

    \li \l {QOpenGLWidget}{QOpenGLWidget} is a widget that allows adding OpenGL
    scenes into QWidget-based user interfaces.

    \li \l {Mixing Scene Graph and OpenGL}{OpenGL and Qt Quick 2.0} -
    How to integrate OpenGL into a the Qt Quick 2.0 scene graph.

    \li \l {http://www.khronos.org/opengl}{www.khronos.org/opengl} -
    The official OpenGL pages.

    \li \l[QtCanvas3D]{Qt Canvas 3D} - An add-on module that provides a way to
        make OpenGL-like 3D drawing calls from Qt Quick using JavaScript.

\endlist

Prior to Qt 5.0, OpenGL support in Qt was handled by the \l {Qt OpenGL}
module. This module is still present, but new code should aim to use
the new classes in the \l {Qt GUI} module. The classes are easily distinguisible
based on their names: Classes with the \c QGL prefix should not be used. Instead,
prefer the ones starting with \c QOpenGL.



\section1 Qt Quick Scene Graph

Qt Quick 2 introduces an OpenGL (ES) 2.0 scene graph for
rendering. It generally improves the performance of Qt Quick 2
significantly compared to the QGraphicsView/QPainter-based approach
used in earlier versions.

The scene graph is a graphical representation of the Item scene. It
can be thought of as a graphical deep copy, an independent structure
that contains enough information to render all the items. Once it has
been set up, it can be manipulated and rendered independently of the
state of the items. On many platforms, the scene graph will even be
rendered on a dedicated render thread while the GUI thread is
preparing the next frame's state.

The scene graph is used when you import QtQuick 2.x in your QML
file, and use QQuickView to run it.

\list

    \li \l {qtquick-visualcanvas-scenegraph.html}{Qt Quick Scene Graph}
    - Overview of the Qt Quick Scene Graph architecture.

    \li \l {Scene Graph and Rendering} - Breakdown of the rendering of
    each frame.

\endlist

Qt Quick can be mixed with raw OpenGL rendering by connecting to the
signals \l QQuickWindow::beforeRendering() or \l
QQuickWindow::afterRendering() which are emitted before and after the
Qt Quick scene graph is rendered, respectively.  There signals are
emitted from the render thread (when applicable), and the connections
need to be direct.



\section1 Printing

Qt supports printing both directly to actual printers, locally or on the
network, as well as producing PDF output. How to do printing with
Qt is described in detail on the \l {Qt Print Support} page.



\section1 Images

Qt supports convenient reading, writing, and manipulating of images through the
QImage class. In addition, for more fine grained control of how images are
loaded or saved, you can use the QImageReader and QImageWriter classes
respectively. To add support for additional image formats, outside of the ones
provided by Qt, you can create image format plugins by using QImageIOHandler
and QImageIOPlugin.

See the \l {Reading and Writing Image Files} page for more information.

*/