QString types
( "JPEG file (*.jpeg);;" "Portable Network Graphics file (*.png);;"
"Bitmap file (*.bmp)");
QString jpegExt
=".jpeg", pngExt
=".png", bmpExt
=".bmp";
QString fn
= QFileDialog::getSaveFileName(0, tr
("Save 3D Plot"),
QDir::homePath()+ "/" +suggestedName, types,
&filter
);
// If filename is not a null
// Remove file extension if already there
if ( !fn.isEmpty() )
{
if (fn.contains(jpegExt))
{
fn.remove(jpegExt);
}
else if (fn.contains(pngExt))
{
fn.remove(pngExt);
}
else if (fn.contains(bmpExt))
{
fn.remove(bmpExt);
}
if (filter.contains(pngExt))
{
fn+=pngExt;
IO::save(m_3dPlot, fn, "png" );
}
else if (filter.contains(jpegExt))
{
fn+=jpegExt;
IO::save(m_3dPlot, fn, "jpeg" );
}
else if (filter.contains(bmpExt))
{
fn+=bmpExt;
IO::save(m_3dPlot, fn, "bmp" );
}
}
QString types( "JPEG file (*.jpeg);;"
"Portable Network Graphics file (*.png);;"
"Bitmap file (*.bmp)");
QString filter;
QString jpegExt=".jpeg", pngExt=".png", bmpExt=".bmp";
QString suggestedName = "";
QString fn = QFileDialog::getSaveFileName(0, tr("Save 3D Plot"), QDir::homePath()+ "/" +suggestedName, types, &filter);
// If filename is not a null
// Remove file extension if already there
if ( !fn.isEmpty() )
{
if (fn.contains(jpegExt))
{
fn.remove(jpegExt);
}
else if (fn.contains(pngExt))
{
fn.remove(pngExt);
}
else if (fn.contains(bmpExt))
{
fn.remove(bmpExt);
}
if (filter.contains(pngExt))
{
fn+=pngExt;
IO::save(m_3dPlot, fn, "png" );
}
else if (filter.contains(jpegExt))
{
fn+=jpegExt;
IO::save(m_3dPlot, fn, "jpeg" );
}
else if (filter.contains(bmpExt))
{
fn+=bmpExt;
IO::save(m_3dPlot, fn, "bmp" );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks