Results 1 to 1 of 1

Thread: painting on QGraphicsView

  1. #1
    Join Date
    Aug 2011
    Posts
    19
    Thanks
    9
    Qt products
    Qt4

    Smile 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 ?

    Qt Code:
    1. class TabletCanvas : public QGraphicsView
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void TabletCanvas::drawForeground(QPainter *painter, const QRectF& rect)
    2. {
    3. QPixmap _m(pixmap); // the pixmap keeps user sketch
    4. //_m.setMask(pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor));
    5. _m.setAlphaChannel(pixmap.createMaskFromColor(Qt::white, Qt::MaskOutColor));
    6.  
    7. painter->drawPixmap(0, 0, _m);
    8. }
    To copy to clipboard, switch view to plain text mode 

    The above code works like to "paste" sketch on the images.
    fig2.png

    I want to blend the sketch and 'background' image pieces.

    How to do it ?
    1. Can I get the scene-coordinate pixamap in QGraphicsView:aintEvnet() or drawForeground() ?
    2. Or the user sketch pixmap should be another item in scene ?

    Please give me some suggestions, thank you
    Last edited by chiaminhsu; 26th April 2013 at 10:36.

Similar Threads

  1. Painting Pixels in QGraphicsView
    By cszawisza in forum Newbie
    Replies: 0
    Last Post: 12th April 2012, 09:46
  2. Replies: 2
    Last Post: 8th October 2011, 13:50
  3. Painting problem when QMdiSubWindow is moved over QGraphicsView
    By Jayakrishnan in forum Qt Programming
    Replies: 0
    Last Post: 19th February 2010, 07:51
  4. Replies: 14
    Last Post: 11th January 2010, 16:26
  5. Slow painting in QGraphicsView
    By JonathanForQT4 in forum Qt Programming
    Replies: 12
    Last Post: 16th July 2007, 09:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.