Results 1 to 3 of 3

Thread: how to save the QImage file in the desired directory location?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Windows

    Question how to save the QImage file in the desired directory location?

    Hi Friends,

    i wanted to save the QImage file into the desired directory....i have changed the directory and save the QImage... but it is not saving into the desired directory.....it saves into the application current directory....

    here is my code snippet:
    Qt Code:
    1. QDir *dir = new QDir(".");
    2. if( dir->cd("LSWT_Report"));
    3. if(dir->cd("Report"));
    4. if(dir->cd("Plots"));
    5.  
    6. const double scaleFactor = 3.0;
    7. const QSize sz(3543, 2362);
    8.  
    9. QImage image(sz, QImage::Format_ARGB32);
    10. image.fill( QColor( Qt::white ).rgb() );
    11.  
    12. QPainter painter(&image);
    13. painter.scale(scaleFactor, scaleFactor);
    14.  
    15. QwtPlotRenderer renderer;
    16.  
    17. QString saveFileName;
    18.  
    19. for(int j=0;j<plots.count();j++)
    20. {
    21. if(j==0)
    22. {
    23. saveFileName = "CdVsCl.png";
    24. }
    25. if(j==1)
    26. {
    27. saveFileName = "AOAVsCl.png";
    28. }
    29. if(j==2)
    30. {
    31. saveFileName = "AOAVsCm.png";
    32. }
    33. if(j==3)
    34. {
    35. saveFileName = "AOAVsCd.png";
    36. }
    37. if(j==4)
    38. {
    39. saveFileName = "ClVsClbyCd.png";
    40. }
    41. if(j==5)
    42. {
    43. saveFileName = "AOAVsClbyCd.png";
    44. }
    45.  
    46. renderer.render(plots.at(j), &painter, QRectF( QPointF(0, 0), sz / scaleFactor ) );
    47.  
    48. image.save( saveFileName );
    49.  
    50. }
    To copy to clipboard, switch view to plain text mode 

    please anyone can help me.....

    Thanks in Advance,
    Muthu
    Last edited by high_flyer; 24th March 2011 at 12:53. Reason: code tags

Similar Threads

  1. save Qimage in a file
    By OverTheOCean in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2011, 23:42
  2. Replies: 6
    Last Post: 5th December 2009, 14:46
  3. QIcon Directory Location
    By QbelcorT in forum Qt Tools
    Replies: 4
    Last Post: 28th January 2009, 01:06
  4. Can't save QImage
    By hvengel in forum Qt Programming
    Replies: 6
    Last Post: 14th June 2008, 21:07
  5. Replies: 3
    Last Post: 15th March 2006, 11:44

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
  •  
Qt is a trademark of The Qt Company.