void MyPlot::exportSVG()
{
fileName
= QFileDialog::getSaveFileName(this, tr
("Nome file da esportare"),
QString(),
"Graphic files ( *svg)");
if ( !fileName.isEmpty() )
{
QSvgGenerator generator;
generator.setFileName(fileName);
generator.
setSize(QSize(1024,
800));
filter.setOptions(options);
painter.drawPixmap(0,0,-1,-1,pixmap);
// print(&painter,QRect(0,0,800,600),filter);:confused:
}
}
void MyPlot::exportPNG()
fileName
= QFileDialog::getSaveFileName(this, tr
("Nome file da esportare"),
QString(),
"Graphic files (*.png )");
if ( !fileName.isEmpty() )
{
// int options = QwtPlotPrintFilter::PrintAll;
// int options = ~QwtPlotPrintFilter::PrintBackground;
filter.setOptions(options);
//print(pixmap,filter );:confused:
if ( pixmap.save(fileName, "png" ))
qDebug()<<"ok";
else
qDebug()<<"Uhmm";
}
}
void MyPlot::exportSVG()
{
QString fileName;
fileName = QFileDialog::getSaveFileName(this, tr("Nome file da esportare"), QString(),"Graphic files ( *svg)");
if ( !fileName.isEmpty() )
{
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(QSize(1024, 800));
QwtPlotPrintFilter filter;
int options = QwtPlotPrintFilter::PrintAll;
options |= QwtPlotPrintFilter::PrintBackground;
options |= QwtPlotPrintFilter::PrintFrameWithScales| QwtPlotPrintFilter::PrintMargin;
filter.setOptions(options);
QPixmap pixmap = QPixmap::grabWidget(this);
QPainter painter(&generator);
painter.drawPixmap(0,0,-1,-1,pixmap);
// print(&painter,QRect(0,0,800,600),filter);:confused:
}
}
void MyPlot::exportPNG()
{ QString fileName;
fileName = QFileDialog::getSaveFileName(this, tr("Nome file da esportare"), QString(),"Graphic files (*.png )");
if ( !fileName.isEmpty() )
{
QwtPlotPrintFilter filter;
// int options = QwtPlotPrintFilter::PrintAll;
// int options = ~QwtPlotPrintFilter::PrintBackground;
int options = QwtPlotPrintFilter::PrintFrameWithScales;
options |= QwtPlotPrintFilter::PrintBackground;
filter.setOptions(options);
QPixmap pixmap= QPixmap::grabWidget(this);
//print(pixmap,filter );:confused:
if ( pixmap.save(fileName, "png" ))
qDebug()<<"ok";
else
qDebug()<<"Uhmm";
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks