summaryrefslogtreecommitdiff
path: root/doc/src/highdpi.qdoc
blob: cc9bd290143bbf6b18d0b8d5d76503d39445be82 (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
/****************************************************************************
**
** 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 highdpi.html
    \title High DPI Displays
    \brief Concepts of High DPI Displays

    \section1 High DPI Displays

    High DPI monitors and displays with superb image quality and crisp font rendering
    are becoming increasingly popular. For example, 4K monitors may have 3840x2160 pixels,
    resulting in a logical resolution of 192 DPI, whereas older monitors have around 1920x1080
    pixels at 96 DPI.

    \section2 Issues with High DPI

    High DPI Displays cause a number of issues for existing applications:

    \list
        \li Applications using UI designs with fixed coordinates look small.
            The combination of font size specification in points and other sizes in
            pixels is particularly problematic since points are independent of the monitor
            resolution. For example, a frame of 40x20 pixels around the text "hello"
            using a 12pt font looks correct on low resolution monitors,
            but the frame will be too small on high DPI monitors, causing the text
            to be clipped.

        \li Applications must adapt to situations where users have multiple displays with
            varying resolution.  For example, they might use a 4K monitor for the
            document window of an image editor and a low resolution monitor for the
            tool box.

        \li Backing store and pixmap buffers become quite large so that
            rendering may slow down.
    \endlist

    \section2 Operating System Support

    The operating systems supported by Qt offer the following support for high DPI displays:

    \section3 OS X

    On OS X, there is a separate, float-based user coordinate system (as opposed
    to Device Pixels). For high DPI monitors, the operating system will scale the
    contents using an efficient scaling algorithm that will make everything look
    very crisp (Retina Display).

    \note The scaling is not applied to Open GL windows.

    \section3 Microsoft Windows

    \section4 Scaling

    The user can choose a scaling factor from the control panel or via context menu.
    This works by making the functions for querying the system metrics return
    different values for standard font sizes, sizes of window borders, and so on.
    It does not perform any actual scaling.

    \section4 DPI Awareness

    An application on Windows can assume one of the following levels of "DPI Awareness":

    \table
        \header
            \li DPI Awareness Level
            \li Meaning

        \row
            \li DPI Unaware
            \li This level has been introduced in Windows-Vista. Windows will pretend to the
                application that it is running on a standard display of 96 DPI of 1920x1080
                and scale the application accordingly. It is intended to accommodate older
                applications designed for low DPI displays. Some artifacts may result from
                this type of scaling.

        \row
            \li System-DPI Aware
            \li This level has been introduced in Windows-Vista. It differs from
                \e{Per-Monitor DPI Aware} only when multiple monitors are connected.
                Windows will calculate a scaling suitable for all connected monitors.

        \row
            \li Per-Monitor DPI Aware
            \li This level has been introduced in Windows 8.1. Windows does not perform
                any scaling at all.

    \endtable

    Qt applications by default are \e{Per-Monitor DPI Aware} on Windows 8.1 or \e{System-DPI Aware}
    on older versions of Windows. As of Qt 5.4, the level can be specified by passing a parameter
    to the platform plugin (see \l{Using qt.conf}):

    \code
    <application> -platform windows:dpiawareness=0,1,2
    \endcode

    \section2 Qt Support

    \list
        \li Ability to provide pixmaps or artwork for high resolution:
            see \l{Drawing High Resolution Versions of Pixmaps and Images}.

        \li Qt 5.4 introduces experimental support for scaling by by device pixel ratio
            similar to OS X to the platform plugins for Windows and Unix (XCB).
            This is controlled by the environment variable \c QT_DEVICE_PIXEL_RATIO.
            It can be set to a numerical value to be used as scale factor or \c "auto"
            which causes the scale factor to be determined by checking the monitor size.

            It is recommended to use the \c Fusion style.
    \endlist

    \section2 Migration of Existing Applications

    In order to get an application designed for low DPI values running on a high
    resolution monitors quickly, consider one of the scaling options (let the
    application run as \e{DPI Unaware} on Windows or set the environment
    variable \c QT_DEVICE_PIXEL_RATIO to \c "auto". These options may incur
    some scaling or painting artifacts, though.

    In the longer term, the application should be adapted to run unmodified:

    \list
        \li Always use the qreal versions of the QPainter drawing API.
        \li Size windows and dialogs in relation to the screen size.
        \li Replace hard-coded sizes in layouts and drawing code
            by values calculated from font metrics or screen size.
    \endlist

    \section2 Glossary Of High DPI Terms

    \table
        \header
            \li Term
            \li Definition

        \row
            \li Device Independent Pixels
            \li Pixels used by application (user space), subject to scaling by the operating
                system or Qt.

        \row
            \li Device Pixels
            \li Pixels of the display device.

        \row
            \li Device Pixel Ratio
            \li Scale factor applied by the operating system or Qt.

        \row
            \li Logical DPI
            \li Resolution used for converting font sizes defined in points to font sizes in pixels.
                Typically one of the standard values 96, 128, .. 192.

        \row
            \li Physical DPI
            \li Physical resolution obtained by dividing the size of the monitor by
                the number of pixels.

        \row
            \li Retina Display
            \li See \l{http://en.wikipedia.org/wiki/Retina_Display}{Wikipedia on Retina Displays}

        \row
            \li User Space
            \li The coordinate space the application uses (Device Independent Pixels).

    \endtable
*/