Qt 5.10 Book Examples
ImageDraw.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // ImageDraw.cpp
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #include <QtGui>
12 #include "ImageDraw.h"
13 
14 // ----------------------------------------------------------------------
15 ImageDraw::ImageDraw(QWidget* pwgt/*=0*/) : QWidget(pwgt)
16 {
17 }
18 
19 // ----------------------------------------------------------------------
21 {
22 }
23 
24 // ----------------------------------------------------------------------
25 /*virtual*/ void ImageDraw::paintEvent(QPaintEvent*)
26 {
27  QImage img(size(), QImage::Format_ARGB32_Premultiplied);
28  QPainter painter;
29 
30  painter.begin(&img);
31  painter.setRenderHint(QPainter::Antialiasing, true);
32  painter.eraseRect(rect());
33  painter.drawEllipse(0, 0, size().width(), size().height());
34  painter.end();
35 
36  painter.begin(this);
37  painter.drawImage(0, 0, img);
38  painter.end();
39 }
ImageDraw(QWidget *pwgt=0)
Definition: ImageDraw.cpp:15
virtual void paintEvent(QPaintEvent *pe)
Definition: ImageDraw.cpp:25
virtual ~ImageDraw()
Definition: ImageDraw.cpp:20