#include <circlewidget.h>
Inheritance diagram for CircleWidget:


Definition at line 29 of file circlewidget.h.
Public Slots | |
| void | nextAnimationFrame () |
Public Member Functions | |
| CircleWidget (QWidget *parent=0) | |
| void | setFloatBased (bool floatBased) |
| void | setAntialiased (bool antialiased) |
| QSize | minimumSizeHint () const |
| QSize | sizeHint () const |
Protected Member Functions | |
| void | paintEvent (QPaintEvent *event) |
Private Attributes | |
| bool | floatBased |
| bool | antialiased |
| int | frameNo |
| CircleWidget::CircleWidget | ( | QWidget * | parent = 0 |
) |
Definition at line 30 of file circlewidget.cpp.
References antialiased, QPalette::Base, QSizePolicy::Expanding, floatBased, frameNo, QWidget::setBackgroundRole(), and QWidget::setSizePolicy().
00031 : QWidget(parent) 00032 { 00033 floatBased = false; 00034 antialiased = false; 00035 frameNo = 0; 00036 00037 setBackgroundRole(QPalette::Base); 00038 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 00039 }
Here is the call graph for this function:

| void CircleWidget::setFloatBased | ( | bool | floatBased | ) |
Definition at line 41 of file circlewidget.cpp.
References QWidget::update().
00042 { 00043 this->floatBased = floatBased; 00044 update(); 00045 }
| void CircleWidget::setAntialiased | ( | bool | antialiased | ) |
Definition at line 47 of file circlewidget.cpp.
References QWidget::update().
00048 { 00049 this->antialiased = antialiased; 00050 update(); 00051 }
| QSize CircleWidget::minimumSizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 53 of file circlewidget.cpp.
00054 { 00055 return QSize(50, 50); 00056 }
| QSize CircleWidget::sizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 58 of file circlewidget.cpp.
00059 { 00060 return QSize(180, 180); 00061 }
| void CircleWidget::nextAnimationFrame | ( | ) | [slot] |
| void CircleWidget::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events which are passed in the event parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint() does not permit this optimization, so we suggest using update() whenever possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.
The background can be set using setBackgroundRole() and setPalette().
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent() to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
...
extern void qt_x11_set_global_double_buffer(bool);
qt_x11_set_global_double_buffer(false);
...
Reimplemented from QWidget.
Definition at line 69 of file circlewidget.cpp.
References alpha, antialiased, QPainter::Antialiasing, QPainter::drawEllipse(), floatBased, frameNo, QWidget::height(), QPainter::setPen(), QPainter::setRenderHint(), QPainter::translate(), and QWidget::width().
00070 { 00071 QPainter painter(this); 00072 painter.setRenderHint(QPainter::Antialiasing, antialiased); 00073 painter.translate(width() / 2, height() / 2); 00074 00075 for (int diameter = 0; diameter < 256; diameter += 9) { 00076 int delta = abs((frameNo % 128) - diameter / 2); 00077 int alpha = 255 - (delta * delta) / 4 - diameter; 00078 if (alpha > 0) { 00079 painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3)); 00080 00081 if (floatBased) { 00082 painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, 00083 diameter, diameter)); 00084 } else { 00085 painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, 00086 diameter, diameter)); 00087 } 00088 } 00089 } 00090 }
Here is the call graph for this function:

bool CircleWidget::floatBased [private] |
bool CircleWidget::antialiased [private] |
int CircleWidget::frameNo [private] |
Definition at line 51 of file circlewidget.h.
Referenced by CircleWidget(), nextAnimationFrame(), and paintEvent().
1.5.1