Results 1 to 2 of 2

Thread: how to save an edited image from qgraphicsview completely in QT

  1. #1
    Join Date
    Mar 2014
    Qt products
    MacOS X Windows

    Question how to save an edited image from qgraphicsview completely in QT

    I am writing codes to load in image from a file and did some edits on this image(change some pixels' value), zoomed in or zoomed out and then save the image. I tried to use qgraphicview and qgraphicsscene to save the image. However, when I tried to save the image, it always save the visible region of the scene. My purpose is to save the edited image in original resolution. Below are my codes.

    Loading part:
    void ImageViewer::loadFile(const QString &fileName)
    if (!fileName.isEmpty()) {
    image = new QImage(fileName);
    if (image->isNull()) {
    QMessageBox::information(this, tr("Image Viewer"),
    tr("Cannot load %1.").arg(fileName));
    qgraphicsscene = myqgraphicsview->getScene();
    currentName = fileName;

    Editing part:
    scene->addEllipse(pt.x()-rad, pt.y()-rad, rad*2.0, rad*2.0, QPen(), QBrush(Qt::SolidPattern));

    Saving part:
    QPixmap pixMap = QPixmap::grabWidget(myqgraphicsview);;
    I think the problem may be in saving part. I tried to find a method in QGraphicsScene that can extract image from it, but failed. Can someone help with that? Thank you very much!!!

  2. #2
    Join Date
    Oct 2006
    New Delhi, India
    Thanked 334 Times in 317 Posts
    Qt products
    Unix/X11 Windows

    Default Re: how to save an edited image from qgraphicsview completely in QT

    May be QGraphicsView::render will help you

Similar Threads

  1. ScrollArea save as image
    By jackajack01 in forum Qt Programming
    Replies: 9
    Last Post: 22nd August 2012, 07:34
  2. Save QGraphicsView Image completely
    By arunkumaraymuo1 in forum General Programming
    Replies: 1
    Last Post: 15th July 2012, 14:51
  3. Replies: 4
    Last Post: 29th May 2012, 23:37
  4. Qwt & save as image
    By giostau in forum Qwt
    Replies: 1
    Last Post: 8th February 2012, 14:41
  5. QGraphicsView: Save as PNG without displaying View?
    By SixDegrees in forum Qt Programming
    Replies: 0
    Last Post: 8th October 2010, 22:56

Tags for this Thread


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.