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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QImage image(100, 100, QImage::Format_RGB32);
QPainterPath path;
path.addRect(20, 20, 60, 60);
path.moveTo(0, 0);
path.cubicTo(99, 0, 50, 50, 99, 99);
path.cubicTo(0, 99, 50, 50, 0, 0);
QPainter painter(&image);
painter.fillRect(0, 0, 100, 100, Qt::white);
painter.save();
painter.translate(0.5, 0.5);
painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
painter.setBrush(QColor(122, 163, 39));
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
painter.restore();
painter.end();
QLabel lab;
lab.setPixmap(QPixmap::fromImage(image));
lab.show();
return app.exec();
}
|