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:
Code:
if( dir->cd("LSWT_Report"));
if(dir->cd("Report"));
if(dir->cd("Plots"));
const double scaleFactor = 3.0;
const QSize sz
(3543,
2362);
image.
fill( QColor( Qt
::white ).
rgb() );
painter.scale(scaleFactor, scaleFactor);
QwtPlotRenderer renderer;
for(int j=0;j<plots.count();j++)
{
if(j==0)
{
saveFileName = "CdVsCl.png";
}
if(j==1)
{
saveFileName = "AOAVsCl.png";
}
if(j==2)
{
saveFileName = "AOAVsCm.png";
}
if(j==3)
{
saveFileName = "AOAVsCd.png";
}
if(j==4)
{
saveFileName = "ClVsClbyCd.png";
}
if(j==5)
{
saveFileName = "AOAVsClbyCd.png";
}
renderer.
render(plots.
at(j
),
&painter,
QRectF( QPointF(0,
0), sz
/ scaleFactor
) );
image.save( saveFileName );
}
please anyone can help me.....
Thanks in Advance,
Muthu
Re: how to save the QImage file in the desired directory location?
Why do you put your cd's in if statements if you are not evaluating the results??
Also, if you are hard coding the directories to change to, you can just as well put it in one path setting.
But since you are NOT using the dir variable don't need it!
And, you are giving QImage only the image name:
Code:
...
saveFileName = "CdVsCl.png";
...
image.save( saveFileName );
So no woder it gets saved to the working directory.
Try this code:
Code:
//This whole block of code is doing nothing !! get rid of it!
//QDir *dir = new QDir(".");
// if( dir->cd("LSWT_Report"));
// if(dir->cd("Report"));
// if(dir->cd("Plots"));
//chaneg your saving line to:
image.save( ".\\LSWT_Report\\Report\\Plots\\"+saveFileName );
Re: how to save the QImage file in the desired directory location?
Thanks for your reply....
it works as per the expectation...