1 Attachment(s)
painting on QGraphicsView
Hi,
I have to design a canvas where users can drag & drop images as background and paint by tablet.
I use view/scene to drag & drop the background images. After switching mode, user sketch can be captured in a pixmap after tablet events.
However, how can I blend the pixmap (user sketch) into the background images ?
Code:
void TabletCanvas
::drawForeground(QPainter *painter,
const QRectF
& rect
) {
QPixmap _m
(pixmap
);
// the pixmap keeps user sketch //_m.setMask(pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor));
_m.setAlphaChannel(pixmap.createMaskFromColor(Qt::white, Qt::MaskOutColor));
painter->drawPixmap(0, 0, _m);
}
The above code works like to "paste" sketch on the images.
Attachment 8992
I want to blend the sketch and 'background' image pieces.
How to do it ?
1. Can I get the scene-coordinate pixamap in QGraphicsView::paintEvnet() or drawForeground() ?
2. Or the user sketch pixmap should be another item in scene ?
Please give me some suggestions, thank you