blob: 6265c806bb9e66f396a222793864174094b7cd2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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]
|