Take a look at QPixmap and try somethihng like this:
void Plot::saveAS()
{
pixmap.fill(Qt::transparent);
// options &= ~QwtPlotPrintFilter::PrintBackground;
// options &= ~QwtPlotPrintFilter::PrintGrid;
filter.setOptions(options);
if(!pixmap.isNull()){
QString fileName
= QFileDialog::getSaveFileName(this, tr
("Save the file as..."),
QDir::currentPath(), tr
("JPEG (*.jpg);;Portable Network Graphics (*.png)"));
if (!fileName.isEmpty()){
if(fileName.endsWith(".png")){
this->print(pixmap, filter);
pixmap.save(fileName, "PNG");
}
else if(fileName.endsWith(".jpg")){
this->print(pixmap, filter);
pixmap.save(fileName, "JPG");
}
else{
return;
}
}
}
void Plot::saveAS()
{
QPixmap pixmap(this->size());
pixmap.fill(Qt::transparent);
QwtPlotPrintFilter filter;
int options = QwtPlotPrintFilter::PrintAll;
// options &= ~QwtPlotPrintFilter::PrintBackground;
// options &= ~QwtPlotPrintFilter::PrintGrid;
filter.setOptions(options);
if(!pixmap.isNull()){
QString fileName = QFileDialog::getSaveFileName(this, tr("Save the file as..."), QDir::currentPath(), tr("JPEG (*.jpg);;Portable Network Graphics (*.png)"));
if (!fileName.isEmpty()){
if(fileName.endsWith(".png")){
this->print(pixmap, filter);
pixmap.save(fileName, "PNG");
}
else if(fileName.endsWith(".jpg")){
this->print(pixmap, filter);
pixmap.save(fileName, "JPG");
}
else{
return;
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks