High DPI and Icons
-
I've got some Icons that I have created as 32x16 and 64x32 with intention of supporting High-DPI:
They are currently in files with names like
DarkColour-16.png and DarkColour-32.png
I think it's possible to create a QIcon object that would automatically choose the right file?
I want in my code to have e.g.
static inline const std::vector<QIcon> icons { QIcon("qrc:///stacking/DarkColour-16.png"), etc... }
and have it pick up the higher res file "automagically".
Is that done with special (maybe different naming conventions)?
-
@Perdrix said in High DPI and Icons:
and have it pick up the higher res file "automagically".
See QIcon::addFile()
-
So for clarity, if I have the resources set up like this:
static inline const std::vector<QIcon> icons { QIcon("qrc:///stacking/DarkColour.png"), // 32 wide 16 high etc... }
and I then set the display Icon for the row of the TableModel to icons[0], it will automatically load use the x2 version of the icon as it builds the vector? That seems to be what the addFile documentation suggests?
Is that right?
Thanks David
-
@Perdrix said in High DPI and Icons:
Is that right?
If you don't trust the documentation simply try it out.
-
@Perdrix said in High DPI and Icons:
I'm in the middle of a 20k + line change to some code that uses this ...
A small example with ~20loc would have told your understanding is correct or not.