summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/examples/tablet.qdoc2
-rw-r--r--doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp33
2 files changed, 34 insertions, 1 deletions
diff --git a/doc/src/examples/tablet.qdoc b/doc/src/examples/tablet.qdoc
index 3b2caf3..95acc69 100644
--- a/doc/src/examples/tablet.qdoc
+++ b/doc/src/examples/tablet.qdoc
@@ -48,7 +48,7 @@
\image tabletexample.png
When you use a tablet with Qt applications, \l{QTabletEvent}s are
- genarated. You need to reimplement the
+ generated. You need to reimplement the
\l{QWidget::}{tabletEvent()} event handler if you want to handle
tablet events. Events are generated when the device used for
drawing enters and leaves the proximity of the tablet (i.e., when
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]
+