diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-03-10 11:41:05 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-03-10 13:08:27 (GMT) |
commit | ed719fefdb4e6fa3fd4c296c1042dfa0454169c6 (patch) | |
tree | 31044b0c47a0b5c2be2efdc28b4706e128f0bb70 /tests/manual/repaint/shared/shared.h | |
parent | 5fa84eeac031ef53babfa8ca616ca69cc1f2c514 (diff) | |
download | Qt-ed719fefdb4e6fa3fd4c296c1042dfa0454169c6.zip Qt-ed719fefdb4e6fa3fd4c296c1042dfa0454169c6.tar.gz Qt-ed719fefdb4e6fa3fd4c296c1042dfa0454169c6.tar.bz2 |
Import static contents tests from old manualtests
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()); + } + } +}; |