00001
00002
00003
00004
00005
00006
00007
00008 #include "PSQt/shapes.h"
00009 #include <QApplication>
00010 #include <QPainter>
00011 #include <QPainterPath>
00012
00013 namespace PSQt {
00014
00015 Shapes::Shapes(QWidget *parent)
00016 : QWidget(parent)
00017 {
00018 }
00019
00020 void Shapes::paintEvent(QPaintEvent *event)
00021 {
00022 QPainter painter(this);
00023
00024 painter.setRenderHint(QPainter::Antialiasing);
00025 painter.setPen(QPen(QBrush("#575555"), 1));
00026
00027 QPainterPath path1;
00028
00029 path1.moveTo(5, 5);
00030 path1.cubicTo(40, 5, 50, 50, 99, 99);
00031 path1.cubicTo(5, 99, 50, 50, 5, 5);
00032 painter.drawPath(path1);
00033
00034 painter.drawPie(130, 20, 90, 60, 30*16, 120*16);
00035 painter.drawChord(240, 30, 90, 60, 0, 16*180);
00036 painter.drawRoundRect(20, 120, 80, 50);
00037
00038 QPolygon polygon;
00039 polygon << QPoint(130, 140) << QPoint(180, 170)
00040 << QPoint(180, 140) << QPoint(220, 110)
00041 << QPoint(140, 100);
00042 painter.drawPolygon(polygon);
00043
00044 painter.drawRect(250, 110, 60, 60);
00045
00046 QPointF baseline(20, 250);
00047 QFont font("Georgia", 55);
00048 QPainterPath path2;
00049 path2.addText(baseline, font, "Q");
00050 painter.drawPath(path2);
00051
00052 painter.drawEllipse(140, 200, 60, 60);
00053 painter.drawEllipse(240, 200, 90, 60);
00054 }
00055
00056 }