Results 1 to 2 of 2

Thread: Rendering QGraphicsScene to QPixmap to save

  1. #1
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Rendering QGraphicsScene to QPixmap to save

    I am trying to save a QGraphicsScene to a QPixmap so that I can save the image. The reason that I am trying to do this is because I have created a gui to go with some research that I am doing and need to get some graphics for a paper I am writing.

    here is how I am doing it right now. I know it is not working because I am getting a false returned from the QPixmap save function. Scene is my QGraphicsScene with an image on it.

    void Control::save_graph()
    {
    QPixmap *tosave = new QPixmap(1000,400);
    QPainter painter(tosave);
    scene->render(&painter);
    painter.end();
    if(tosave->save("Users/user/image","PNG"))printf("save is good");
    else printf("save no good");


    }

    Any help here would be greatly appreciated.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rendering QGraphicsScene to QPixmap to save

    Is the path you are saving to valid ? Just try toSave->save("image","PNG");

    Also you can query sceneRect() and construct the pixmap based on this size

Similar Threads

  1. I want to save and retrive a QGraphicsScene
    By c_srikanth1984 in forum Qt Programming
    Replies: 16
    Last Post: 7th January 2014, 14:19
  2. Position in a QPixMap created from a QGraphicsScene
    By stevel in forum Qt Programming
    Replies: 8
    Last Post: 8th April 2009, 22:39
  3. QPixmap display on QGraphicsScene
    By febil in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2009, 09:27
  4. How could I save Items on a QGraphicsScene?
    By pinkfrog in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2009, 05:03
  5. Replies: 0
    Last Post: 7th April 2008, 14:27

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.