Unsolved How to make ToolButton DPI independant?
-
I have a QML app with a ToolBar with ToolButtons that uses 24x24 images like this:
ToolButton { contentItem: Image { source: "Icons/idea.png" } }
and I have an impression that if the pixel ratio is 2.0, for example, the button shows the stretched image that takes 24 logical pixels that is 48 physical pixels.
If I specify 48x48 image, the button becomes two times bigger, so looks like, the button calculates its site depending on the logical image size and settings the button size does not take an effect:
ToolButton { width: 24 height: 24 contentItem: Image { source: "Icons/idea48.png" } }
Finally it is not clear enough what is the idea this behaviour is based on? And probably I am thinking in a wrong direction, but my first guess is that I should make my ToolButton image take 24x24 logical pixels, but actually be 24, 32 or 48 pixels depending on the pixel density, anyway I should not show stretched image to the user, but all the images should be shown at their original size.
-
@Dmitriano
so what exactly is the difference to your previous post?! -
@raven-worx probably I misunderstood something, but it is not clear why the button change its size (in logical pixels) if I set the image source depending on the pixel density (as described here, and how to prevent it from changing the size.
also it is not clear why the image size is ignored? In the code below the image on the screen is 48x48 logical pixels, but I set 24x24:
ToolButton { contentItem: Image { source: "Icons/idea48.png" width: 24 height: 24 sourceSize: { width: 48 height: 48 } } }
event setting fillMode to Image.Stretch or Image.PreserveAspectFit does not help.