Results 1 to 2 of 2

Thread: Rendering a QGraphicsItem

  1. #1
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Rendering a QGraphicsItem

    Hi,

    I'm trying to create an off-screen render of a QGraphicsItem before the application main window is shown.

    My code that creates the is like this:

    Qt Code:
    1. QPixmap* myObject::preview()
    2. {
    3. QPixmap* image = new QPixmap(boundingRect().size().toSize());
    4. image->fill(QColor());
    5. QPainter imagePainter(image);
    6. imagePainter.translate(-boundingRect().topLeft());
    7.  
    8. paint(&imagePainter, 0, 0);
    9.  
    10. imagePainter.end();
    11.  
    12. return image;
    13. }
    To copy to clipboard, switch view to plain text mode 


    I'm getting this error, which I cannot find documentation for:

    QPainter::begin: Paint device returned engine == 0, type: 2
    QPainter::translate: Painter not active
    QPainter::end: Painter not active, aborted

    A thread from back in 2007 seems to suggest that the code above should work.
    http://lists.trolltech.com/qt-intere...ad00089-0.html

    Any ideas?

    Thanks
    Jonks

  2. #2
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Rendering a QGraphicsItem

    Solved! - boundingRect() was returning (0,0)

Similar Threads

  1. Replies: 2
    Last Post: 25th March 2011, 09:18
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. Replies: 1
    Last Post: 25th February 2009, 00:34
  4. Rendering 3D Objects on Ubuntu
    By Sandip in forum Qt Programming
    Replies: 3
    Last Post: 19th January 2009, 14:29
  5. Snap-to grid on QGraphicsItem
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 28th April 2008, 16:22

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.