diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-24 13:32:24 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-24 17:21:26 (GMT) |
commit | 2823ca13453d354911b065e018dda4d17a06f6d2 (patch) | |
tree | 6829711848a5f285831f3ba658fefc6b763e2230 /doc/src | |
parent | a8574172dd5e6bc11cf6f69b6fad5a063549e88d (diff) | |
download | Qt-2823ca13453d354911b065e018dda4d17a06f6d2.zip Qt-2823ca13453d354911b065e018dda4d17a06f6d2.tar.gz Qt-2823ca13453d354911b065e018dda4d17a06f6d2.tar.bz2 |
doc: More documentation of the graphics effect framework.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp new file mode 100644 index 0000000..6265c80 --- /dev/null +++ b/doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp @@ -0,0 +1,33 @@ +//! [0] +MyGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +{ + // Fully opaque; draw directly without going through a pixmap. + if (qFuzzyCompare(m_opacity, 1)) { + source->draw(painter); + return; + } + ... +} +//! [0] + +//! [1] +MyGraphicsEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +{ + ... + QPoint offset; + if (source->isPixmap()) { + // No point in drawing in device coordinates (pixmap will be scaled anyways). + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + ... + painter->drawPixmap(offset, pixmap); + } else { + // Draw pixmap in device coordinates to avoid pixmap scaling; + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + painter->setWorldTransform(QTransform()); + ... + painter->drawPixmap(offset, pixmap); + } + ... +} +//! [1] + |