Qt 5.10 Book Examples
Ellipse.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // Ellipse.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 <QPainter>
12 #include "Ellipse.h"
13 
14 // ----------------------------------------------------------------------
15 Ellipse::Ellipse(QQuickItem* pqi /*= 0*/) : QQuickPaintedItem(pqi)
16  , m_color(Qt::black)
17 {
18 }
19 
20 // ----------------------------------------------------------------------
21 void Ellipse::paint(QPainter* ppainter)
22 {
23  ppainter->setRenderHint(QPainter::Antialiasing, true);
24  ppainter->setBrush(QBrush(colorValue()));
25  ppainter->setPen(Qt::NoPen);
26  ppainter->drawEllipse(boundingRect());
27 }
28 
29 // ----------------------------------------------------------------------
30 QColor Ellipse::colorValue() const
31 {
32  return m_color;
33 }
34 
35 // ----------------------------------------------------------------------
36 void Ellipse::setColorValue(const QColor& col)
37 {
38  m_color = col;
39 }
Ellipse(QQuickItem *pqi=0)
Definition: Ellipse.cpp:15
QColor colorValue() const
Definition: Ellipse.cpp:30
void setColorValue(const QColor &)
Definition: Ellipse.cpp:36
void paint(QPainter *ppainter)
Definition: Ellipse.cpp:21