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
doc_src_coordsys.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QPainter>
4#include <QWidget>
5
6namespace doc_src_coordsys {
7struct SnippetWrappers : public QWidget
8{
9 void wrapper0();
10 void wrapper1();
11 void wrapper2();
12 void wrapper3();
13 void wrapper4();
14};
15
16
18
19//! [0]
20QPainter painter(this);
21
22painter.setPen(Qt::darkGreen);
23// Using the (x y w h) overload
24painter.drawRect(1, 2, 6, 4);
25//! [0]
26
27} // wrapper0
28
29
31
32//! [1]
33QPainter painter(this);
34
35painter.setPen(Qt::darkGreen);
36painter.drawLine(2, 7, 6, 1);
37//! [1]
38
39} // wrapper2
40
41
43
44//! [2]
45QPainter painter(this);
46painter.setRenderHint(
47 QPainter::Antialiasing);
48painter.setPen(Qt::darkGreen);
49// Using the (x y w h) overload
50painter.drawRect(1, 2, 6, 4);
51//! [2]
52
53} // wrapper2
54
55
57
58//! [3]
59QPainter painter(this);
60painter.setRenderHint(
61 QPainter::Antialiasing);
62painter.setPen(Qt::darkGreen);
63painter.drawLine(2, 7, 6, 1);
64//! [3]
65
66} // wrapper3
67
68
70
71//! [4]
72QPainter painter(this);
73painter.setWindow(QRect(-50, -50, 100, 100));
74//! [4]
75
76
77//! [5]
78int side = qMin(width(), height());
79int x = (width() - side / 2);
80int y = (height() - side / 2);
81
82painter.setViewport(x, y, side, side);
83//! [5]
84
85} // wrapper4
86
87} // doc_src_coordsys