QwtPlotRenderer renderer;renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground);renderer.setDiscardFlag(QwtPlotRenderer::DiscardLegend);qreal widthMm = printer->pageRect(QPrinter::Millimeter).width();qreal heightMm = printer->pageRect(QPrinter::Millimeter).height();qint16 widthPx = widthMm / 0.2646;qint16 heightPx = heightMm / 0.2646;QSizeF size(widthMm, heightMm);renderer.renderDocument(_currentChart->getChartPlot(), imagePlotPath, size, ui->spinBoxImageResolution->value());
C++ (Qt) QImage im(widthPx, heightPx, QImage::Format_RGB32); im.fill(Qt::lightGray); renderer.renderTo(w.plot_, im); im.save("C:/temp/image2.png");
QPalette palette = scaleWidget->palette();int width = scaleWidget->width();int height = scaleWidget->height();QLinearGradient linearGradient(QPointF(0, 0), QPointF(width, height));linearGradient.setColorAt(0.0, _chartPlot->canvasBackground().color());linearGradient.setColorAt(0.9, color.lighter());linearGradient.setColorAt(1.0, color);QBrush brush(linearGradient);palette.setBrush(QPalette::Background, linearGradient);scaleWidget->setPalette(palette);
C++ (Qt)void QwtPlotRenderer::renderScale( const QwtPlot *plot, QPainter *painter, int axisId, int startDist, int endDist, int baseDist, const QRectF &rect ) const{ //... double x, y, w; switch ( axisId ) { case QwtPlot::yLeft: { x = rect.right() - 1.0 - baseDist; y = rect.y() + startDist; w = rect.height() - startDist - endDist; align = QwtScaleDraw::LeftScale; break; }