QCustomPlot Discussion and Comments

Fixing HiDPI printing problems on WindowsReturn to overview

No matter what I try, the axis labels are drawn very large and are cutoff in the output to a printer. I am using the recommended code for rendering. Please note that only Windows HiDPI (e.g. 200% display scaling) suffers from this issue, the identical code on Linux (KDE Plasma) and macOS (Retina displays) Qt distributions works perfectly.

I noticed in the code:

void QCustomPlot::setBufferDevicePixelRatio(double ratio)
{
  if (!qFuzzyCompare(ratio, mBufferDevicePixelRatio))
  {
#ifdef QCP_DEVICEPIXELRATIO_SUPPORTED
    mBufferDevicePixelRatio = ratio;
    foreach(QSharedPointer<QCPAbstractPaintBuffer> buffer, mPaintBuffers)
    {
        buffer->setDevicePixelRatio(mBufferDevicePixelRatio);
        // Note: axis label cache has devicePixelRatio as part of cache hash, so no need to manually clear cache here
    }
#else
    qDebug() << Q_FUNC_INFO << "Device pixel ratios not supported for Qt versions before 5.4";
    mBufferDevicePixelRatio = 1.0;
#endif
  }
}

I think the axis label cache may NOT have the correct pixel ratio? How do I "manually clear" the labels cache? I thought this might be a hint since it is only the labels that seem unable to draw correctly.

This is a longstanding bug with Windows HiDPI and output to a printer with QCustomPlot.

Here is a screencap of the printer preview showing the bug:

https://www.gamesforone.com/beta/hidpi-printing-problem.png