Results 1 to 2 of 2

Thread: How do I get a Qpixmap or QImage from a QGraphicsView without show()+grabWidget()

  1. #1
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How do I get a Qpixmap or QImage from a QGraphicsView without show()+grabWidget()

    I have tried following


    Qt Code:
    1.  
    2. QImager img;
    3. QPainter painter(&img);
    4. view.render(&painter);
    5. painter,end();
    6.  
    7. img.save("./image.png");
    To copy to clipboard, switch view to plain text mode 

    Problem with this approach is that view does not update before rendering onto painter. Calling view.update() did not help either.
    Any help is appreciated.

    thanks
    Last edited by anda_skoa; 15th June 2016 at 09:34. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How do I get a Qpixmap or QImage from a QGraphicsView without show()+grabWidget(

    Since you don't seem to need the view, have you tried rendering the scene itself instead?

    Cheers,
    _

Similar Threads

  1. Drawing Cursor with QPixmap::grabWidget
    By cranberries in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2015, 05:34
  2. Replies: 1
    Last Post: 21st August 2008, 08:44
  3. problem with QPixmap::grabWidget()
    By momesana in forum Qt Programming
    Replies: 6
    Last Post: 19th October 2007, 01:57
  4. performance issue(QGV + QPixmap::grabWidget)
    By momesana in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2007, 12:31
  5. QPixmap::GrabWidget
    By kemp in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 11:30

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.