1
/****************************************************************************
3
** Copyright (C) 2005-2005 Trolltech AS. All rights reserved.
5
** This file is part of the example classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
31
#include "renderarea.h"
33
RenderArea::RenderArea(QWidget *parent)
38
pixmap.load(":/images/qt-logo.png");
40
setBackgroundRole(QPalette::Base);
43
QSize RenderArea::minimumSizeHint() const
45
return QSize(100, 100);
48
QSize RenderArea::sizeHint() const
50
return QSize(400, 200);
53
void RenderArea::setShape(Shape shape)
59
void RenderArea::setPen(const QPen &pen)
65
void RenderArea::setBrush(const QBrush &brush)
71
void RenderArea::setAntialiased(bool antialiased)
73
this->antialiased = antialiased;
77
void RenderArea::setTransformed(bool transformed)
79
this->transformed = transformed;
83
void RenderArea::paintEvent(QPaintEvent *)
85
static const int polygonPoints[8] = { 10, 80, 20, 10, 80, 30, 90, 70 };
86
QPolygon polygon(4, polygonPoints);
88
QRect rect(10, 20, 80, 60);
93
path.cubicTo(80, 0, 50, 50, 80, 80);
95
int startAngle = 30 * 16;
96
int arcLength = 120 * 16;
98
QPainter painter(this);
100
painter.setBrush(brush);
102
painter.setRenderHint(QPainter::Antialiasing);
104
for (int x = 0; x < width(); x += 100) {
105
for (int y = 0; y < height(); y += 100) {
107
painter.translate(x, y);
109
painter.translate(50, 50);
110
painter.rotate(60.0);
111
painter.scale(0.6, 0.9);
112
painter.translate(-50, -50);
117
painter.drawLine(rect.bottomLeft(), rect.topRight());
120
painter.drawPoints(polygon);
123
painter.drawPolyline(polygon);
126
painter.drawPolygon(polygon);
129
painter.drawRect(rect);
132
painter.drawRoundRect(rect);
135
painter.drawEllipse(rect);
138
painter.drawArc(rect, startAngle, arcLength);
141
painter.drawChord(rect, startAngle, arcLength);
144
painter.drawPie(rect, startAngle, arcLength);
147
painter.drawPath(path);
150
painter.drawText(rect, Qt::AlignCenter, tr("Qt by\nTrolltech"));
153
painter.drawPixmap(10, 10, pixmap);