diff options
Diffstat (limited to 'tests/manual/repaint/shared/shared.h')
-rw-r--r-- | tests/manual/repaint/shared/shared.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/manual/repaint/shared/shared.h b/tests/manual/repaint/shared/shared.h new file mode 100644 index 0000000..c7edfc1 --- /dev/null +++ b/tests/manual/repaint/shared/shared.h @@ -0,0 +1,40 @@ +#include <QtGui> +class StaticWidget : public QWidget +{ +Q_OBJECT +public: + int hue; + StaticWidget(QWidget *parent = 0) + :QWidget(parent) + { + setAttribute(Qt::WA_StaticContents); + setAttribute(Qt::WA_OpaquePaintEvent); + hue = 200; + } + + void resizeEvent(QResizeEvent *) + { + // qDebug() << "static widget resize from" << e->oldSize() << "to" << e->size(); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + static int color = 200; + color = (color + 41) % 205 + 50; +// color = ((color + 45) %150) + 100; + qDebug() << "static widget repaint" << e->rect(); + p.fillRect(e->rect(), QColor::fromHsv(hue, 255, color)); + p.setPen(QPen(QColor(Qt::white))); + + for (int y = e->rect().top(); y <= e->rect().bottom() + 1; ++y) { + if (y % 20 == 0) + p.drawLine(e->rect().left(), y, e->rect().right(), y); + } + + for (int x = e->rect().left(); x <= e->rect().right() +1 ; ++x) { + if (x % 20 == 0) + p.drawLine(x, e->rect().top(), x, e->rect().bottom()); + } + } +}; |