Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.6.2, 5.9.0 Beta 3, 5.12.4
-
52ce0c177e80c2d5b70b38d429abb3689b3da51e (qt/qtbase/dev) 760df7256588e76d082ea959399af36d7ba80a86 (qt/qtbase/5.15)
Description
Rich text can't handle @2x images:
Given
foo.png foo@2x.png
Then
<img src="foo.png">
Will fail to load the hi-dpi version
The reason is in /src/gui/text/qtextimagehandler.cpp
The function to find the hi-dpi image fails to assign the result to the output QUrl variable
static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio) { ... if (targetDevicePixelRatio <= 1.0) return fileName; // try to find a Nx version return qt_findAtNxFile(fileName, targetDevicePixelRatio, sourceDevicePixelRatio); }
Notice, the url is not updated.
A simple fix can be
const QString res = qt_findAtNxFile(fileName, targetDevicePixelRatio, sourceDevicePixelRatio); if(res != fileName) *url = QUrl(res); return res;
Related bug QTBUG-46777
Attachments
Issue Links
- relates to
-
QTBUG-46777 When using an img tag inside a Text element in QML then it will not check for any HiDPI images
-
- Reported
-
For Gerrit Dashboard: QTBUG-60793 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
266887,3 | Set the url to have the AtNx filename if one is found | 5.14 | qt/qtbase | Status: ABANDONED | -1 | 0 |
304621,4 | Set the url to have the AtNx filename if one is found | dev | qt/qtbase | Status: MERGED | +2 | 0 |
320609,2 | Set the url to have the AtNx filename if one is found | 5.15 | qt/qtbase | Status: MERGED | +2 | 0 |