Make QOpenGLWidget work with QT_WIDGETS_HIGHDPI_DOWNSCALE

Get the DPR from QWidget::metric(), which has a code path
for handling the QT_WIDGETS_HIGHDPI_DOWNSCALE case.

Fixes: QTBUG-111105
Pick-to: 6.5
Change-Id: I821cbdf00423de211719173ae5c0af7b76594f60
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Morten Sørvig 2023-03-02 13:23:28 +01:00 committed by Morten Johan Sørvig
parent 7367cba9eb
commit 433d67e767

View File

@ -1608,15 +1608,9 @@ int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const
else
return qRound(dpmy * 0.0254);
case PdmDevicePixelRatio:
if (window)
return int(window->devicePixelRatio());
else
return 1.0;
return QWidget::metric(metric);
case PdmDevicePixelRatioScaled:
if (window)
return int(window->devicePixelRatio() * devicePixelRatioFScale());
else
return int(devicePixelRatioFScale());
return QWidget::metric(metric);
default:
qWarning("QOpenGLWidget::metric(): unknown metric %d", metric);
return 0;