Hi,

I have a similar code to save the plot as PNG or BMP and works, but with the JPEG file it doesnt work (neigther with JPG)

Here is the code
Qt Code:
  1. QString types( "JPEG file (*.jpeg);;"
  2. "Portable Network Graphics file (*.png);;"
  3. "Bitmap file (*.bmp)");
  4.  
  5.  
  6. QString filter;
  7.  
  8. QString jpegExt=".jpeg", pngExt=".png", bmpExt=".bmp";
  9.  
  10. QString suggestedName = "";
  11.  
  12. QString fn = QFileDialog::getSaveFileName(0, tr("Save 3D Plot"), QDir::homePath()+ "/" +suggestedName, types, &filter);
  13.  
  14. // If filename is not a null
  15. // Remove file extension if already there
  16. if ( !fn.isEmpty() )
  17. {
  18. if (fn.contains(jpegExt))
  19. {
  20. fn.remove(jpegExt);
  21. }
  22. else if (fn.contains(pngExt))
  23. {
  24. fn.remove(pngExt);
  25. }
  26. else if (fn.contains(bmpExt))
  27. {
  28. fn.remove(bmpExt);
  29. }
  30.  
  31. if (filter.contains(pngExt))
  32. {
  33.  
  34. fn+=pngExt;
  35. IO::save(m_3dPlot, fn, "png" );
  36. }
  37. else if (filter.contains(jpegExt))
  38. {
  39.  
  40. fn+=jpegExt;
  41. IO::save(m_3dPlot, fn, "jpeg" );
  42. }
  43. else if (filter.contains(bmpExt))
  44. {
  45.  
  46. fn+=bmpExt;
  47. IO::save(m_3dPlot, fn, "bmp" );
  48. }
  49. }
To copy to clipboard, switch view to plain text mode 

Any ideas? I doesnt work by changing jpeg by JPEG. Wehn I try to save the plot as jpeg file, no file is created.

Thanks