Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
20QPainter painter(this);
21
23// Using the (x y w h) overload
24painter.drawRect(1, 2, 6, 4);
26
27} // wrapper0
28
29
31
33QPainter painter(this);
34
36painter.drawLine(2, 7, 6, 1);
38
39} // wrapper2
40
41
43
45QPainter painter(this);
49// Using the (x y w h) overload
50painter.drawRect(1, 2, 6, 4);
52
53} // wrapper2
54
55
67
68
70
72QPainter painter(this);
73painter.setWindow(QRect(-50, -50, 100, 100));
75
76
78int side = qMin(width(), height());
79int x = (width() - side / 2);
80int y = (height() - side / 2);
81
82painter.setViewport(x, y, side, side);
84
85} // wrapper4
86
87} // doc_src_coordsys
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition qpainter.h:519
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition qpainter.h:442
void setViewport(const QRect &viewport)
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
@ Antialiasing
Definition qpainter.h:52
void setWindow(const QRect &window)
Sets the painter's window to the given rectangle, and enables view transformations.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
\inmodule QtCore\reentrant
Definition qrect.h:30
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
@ darkGreen
Definition qnamespace.h:42
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLint GLint GLint GLint GLint x
[0]
GLint y
QPainter painter(this)
[7]