Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.8, 5.15.5, 6.2.3
Description
QML Images always render SVG, PDF and QQuickImageProvider with a device-pixel-ratio of 1.0, regardless of the actual screen dpi unless sourceSize is set.
This is always pixellated on Hi-DPI screens:
import QtQuick 2.15 Image { source: "icon_extensions.svg" }
This is causing serious difficulty in making QML-based applications support hi-dpi and mixed-dpi platforms, such as Windows 10/11, as sourceSize cannot be set without also explicitly setting the Image height and width.
So far the closest thing I've found to a workaround is to hard-code the device-independent-pixel size of the (eg) SVG into the QML, like so:
import QtQuick 2.15 Image { source: "icon_extensions.svg" // Manually looked up from the SVG sourceSize.width: 24 sourceSize.height: 24 }
This is not generally acceptable, as it means every single Image item has to be set to an explicit size that must match the SVG it loads.
I have not yet found any QML API that exposes the 'original native' size of an Image source.
This does not appear to be related to QTBUG-94855.
The issue seems to be that qquickimagebase explicitly sets a device pixel ratio of 1.0, unless the sourceSize has been overridden or there is an "@2x" version of a bitmap
if (loadOptions & HandleDPR) { const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio()); d->devicePixelRatio = 1.0; bool updatedDevicePixelRatio = false; if (d->sourcesize.isValid()) // BUG!! This check prevents SVG, PDF and QQuickImageProviders from rendering at high quality updatedDevicePixelRatio = d->updateDevicePixelRatio(targetDevicePixelRatio); if (!updatedDevicePixelRatio) { // (possible) local file: loadUrl and d->devicePixelRatio will be modified if // an "@2x" file is found. resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio); } }
Attachments
Issue Links
- relates to
-
QTBUG-98958 Image sourceClipRect has no visual effect on an image from QQuickImageProvider
- Reported
-
QTBUG-103018 QPdfDocument : AntiAliasing flags : turning AA in turns it off
- Reported