[Interest] SVG is loaded with invalid dimensions on some machines

Alexander Dyagilev alervdvcw at gmail.com
Sat Apr 20 09:14:45 CEST 2024


Hello,

Yes, you are wrong.

I've just found that Qt 5.12.12 does not have this issue. So, it seems it's
a bug and I've created bug report:
https://bugreports.qt.io/browse/QTBUG-124574.



On Thu, Apr 18, 2024 at 11:05 PM Elvis Stansvik <elvstone at gmail.com> wrote:

> Den tors 18 apr. 2024 17:11Alexander Dyagilev <alervdvcw at gmail.com> skrev:
>
>> Well, I was able to reproduce the issue.
>> 1. Launch app.
>> 2. Change system zoom settings from 100% to 125%.
>> 3. Done. The issue is here. After restarting app - issue is not
>> reproduced.
>> So, just a guess, on 2-monitor system this zoom settings changes at
>> runtime (maybe app is started initially on some monitor and then moves to
>> another one with different zoom setting).
>> *Question is*: is it possible to disable this auto-zoom thing for a
>> particular image or at least globally?
>>
>
> I dont think so. You need to query the device pixel ratio of the screen
> your widget is currently displayed on and re-rasterize your SVG to the
> appropriate pixel dimensions. You also need to listen for events indicating
> a change in device pixel ratio (i.e. user changing their system
> preferences) and indicating your widget was moved to another monitor where
> the ratio is different, and do the same if that happens. At least that's my
> understanding.
>
> We do the same in our app in places where we paint in physical pixels and
> i think this is par for the course for DPI-aware Qt applications.
>
> I could be wrong.
>
> Elvis
>
>
>> On Thu, Apr 18, 2024 at 9:52 PM Alexander Dyagilev <alervdvcw at gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> The user with the issue has two monitors connected to his PC. *Weird
>>> thing* is that SVG is loaded properly on one monitor (2K) and
>>> improperly on another one (FullHD). How can this be? Only Qt authors can
>>> probably shed some light on this issue :)
>>>
>>>
>>> On Thu, Apr 18, 2024 at 11:24 AM Alexander Dyagilev <alervdvcw at gmail.com>
>>> wrote:
>>>
>>>> Image as it's displayed on the user's machine:
>>>>
>>>> [image: image.png]
>>>>
>>>>
>>>> On Thu, Apr 18, 2024 at 11:21 AM Alexander Dyagilev <
>>>> alervdvcw at gmail.com> wrote:
>>>>
>>>>> I forgot to mention that this happens at least with Qt 6.4.3 and 6.6.2
>>>>> (or 6.6.3 I don't remember exactly). We use this code to load the image:
>>>>>
>>>>> import QtQuick 2.12
>>>>>
>>>>> Image
>>>>> {
>>>>>     property double zoom: 1.0
>>>>>
>>>>>     readonly property int preferredWidth: sameHiddenImg.implicitWidth
>>>>> * zoom
>>>>>     readonly property int preferredHeight:
>>>>> sameHiddenImg.implicitHeight * zoom
>>>>>
>>>>>     // it works buggy under e.g. Retina displays without this
>>>>>     width: preferredWidth
>>>>>     height: preferredHeight
>>>>>
>>>>>     // it works buggy under e.g. Retina displays without this
>>>>>     sourceSize: Qt.size(width, height)
>>>>>
>>>>>     Image
>>>>>     {
>>>>>         id: sameHiddenImg
>>>>>         visible: false
>>>>>         source: parent.source
>>>>>     }
>>>>> }
>>>>>
>>>>> So, valid values for preferredWidth and preferredHeight are 93 and
>>>>> 456. But for some rare users they are 116 and 570 accordingly.
>>>>>
>>>>> On Thu, Apr 18, 2024 at 11:16 AM Alexander Dyagilev <
>>>>> alervdvcw at gmail.com> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> A few of our users have issues with UI rendering. We SVG sprite to
>>>>>> display some elements of our UI. This SVG has a size specified in it
>>>>>> (93x456). And of course we rely on it. The issue is that sometimes it's
>>>>>> loaded with 116x570 size due to some unknown reason. So it's like a
>>>>>> different image and we can't use such a sprite properly anymore.
>>>>>>
>>>>>> What can be the cause of that? I've attached this sprite image.
>>>>>>
>>>>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240420/bb916d8a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 38585 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240420/bb916d8a/attachment.png>


More information about the Interest mailing list