Results 1 to 1 of 1

Thread: capturing a QDeclarativeItem into a QPixmap

  1. #1
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default Re: capturing a QDeclarativeItem into a QPixmap

    I am trying to capture a QDeclarativeItem into a QPixmap to drag it interactively:

    Qt Code:
    1. {
    2. QObject* obj;
    3. draggedPixmap = QPixmap(qobject_cast<QGraphicsItem*>(obj)->
    4. boundingRect().size().toSize());
    5.  
    6. QPainter painter(&draggedPixmap);
    7.  
    8.  
    9. QPointF p(QCursor::pos());
    10.  
    11. qobject_cast<QGraphicsItem*>(obj)->paint(&painter, &option);
    12.  
    13. drag->setPixmap(draggedPixmap);
    14. }
    To copy to clipboard, switch view to plain text mode 

    The problem is, that not all children of the QDeclarativeItem will paint into the QPixmap (say, text won't show up in the QPixmap, but Rectangles will). Calling paint on the Text QDeclarativeItem directly produces garbage. Should I be capturing into a QImage?


    Added after 36 minutes:


    The answer: call GraphicsView::render()!
    Last edited by ugluk; 7th May 2012 at 11:01.

Similar Threads

  1. Replies: 1
    Last Post: 9th February 2012, 10:03
  2. data property in QDeclarativeItem. what is it?
    By moti.lahiani in forum Qt Quick
    Replies: 0
    Last Post: 18th November 2011, 09:03
  3. Replies: 1
    Last Post: 19th April 2011, 11:17
  4. Using a QML model from a QDeclarativeItem subclass
    By humbleguru in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2011, 12:07
  5. Replies: 0
    Last Post: 7th January 2010, 22:03

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.