This is strange. The following code works fine for PNG, BMP and TIF formats, but if I choose the JPG format the image is all black, except for a hint of the frame.
int w = this->width();
int h = this->height();
pixmap.fill(Qt::white);
filter.setOptions(options);
this->print(pixmap, filter);
if (fileName.isEmpty()) {
return;
}
pixmap.save(fileName,0,-1);
int w = this->width();
int h = this->height();
QPixmap pixmap(w, h);
pixmap.fill(Qt::white);
QwtPlotPrintFilter filter;
int options = QwtPlotPrintFilter::PrintAll;
options &= ~QwtPlotPrintFilter::PrintBackground;
options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);
this->print(pixmap, filter);
QString fileName = "zzz.jpg";
if (fileName.isEmpty()) {
return;
}
pixmap.save(fileName,0,-1);
To copy to clipboard, switch view to plain text mode
I invoke this by detecting rightButtonClick on a QwtPlot.
Is there something special about a JPG?
Bookmarks