PDA

View Full Version : QFileIconProvider: available sizes only up to 32x32?



sedi
26th December 2016, 16:57
Hi,
I am using the QFileIconProvider this way:


QFileInfo info = QFileInfo(myFileName);
QFileIconProvider provider;
QIcon icon = provider.icon(info);
qDebug()<<"availableSizes: "<<icon.availableSizes();
(truth be told I am actually meddling around with the SimpleFileBrowser example, so inside the requestPixmap() method I use the m_provider member variable instead of defining the provider for each file)

But, regardless of which file I examine with this, I always get

availableSizes: (QSize(16, 16), QSize(32, 32))
as the only available resolutions. Is it actually true, that there are no larger Icons available or am I doing something wong?
(Windows 10, Qt 5.7.1, MinGw 5.3.0)

Any idea on how to access larger icons?
I've searched around in vain, there also doesn't seem to be an open QtBug in relation with 5.7.x and QFileIconProvider.
What am I missing?

d_stranz
27th December 2016, 03:24
Any idea on how to access larger icons?

Possibly this is something cached by Windows. Try opening your directory in Windows Explorer and setting the view to each of the different icon sizes (Extra Large, Large, Medium, Small and maybe Tile) and see if you get a larger list of available icon sizes.

sedi
27th December 2016, 15:03
Thank you for your time! I have tried all of these settings, I've restarted the program each time. There is no change - just 16x16 and 32x32 icon resolutions are available. Could this be a Qt restriction for performance reason?

NameRakes
27th December 2016, 18:09
I have the same issue (not a big deal, though) with the icons for my actions - Qt wasn't displaying them beyond a certain size. Since there is action titles (Edit, Open, New), tool tip, etc., I didn't bother deploying bigger icons.

sedi
27th December 2016, 19:23
Thanks for confirming the problem! For me it is actually quite important to have 128x128 (or at least 64x64) px, the actual graphic representations for my users will have edge lenghts between 100 and 250 px.

Is this behaviour documented in any way? If yes, I must have missed it. I could understand a reasonable performance compromise, but imho the QFileIconProvider should at least have an non-default option for supplying bigger icons. I can't believe that this is not a problem for many other users...

The only alternative that I see right now is a lenghty list of suffix-based ifs that point to hardcoded and deployed icons. But these would have no reference to the users system settings and possibilities regarding the opening of a file.

d_stranz
28th December 2016, 01:26
You can derive from QFileIconProvider and override the icon() method to add larger / smaller pixmaps to the set of default sizes. You could add these either by scaling existing pixmaps up / down or by creating your own.

sedi
28th December 2016, 03:33
You are right, I can provide my own icons that way, but then they do not reflect the software situation on my user's machine.

But shouldn't QFileIconProvider return bigger icons by default? I've tried to find the answer in the Qt sources, but I don't understand too much of the code there.

The actual work seems to be done in qwindowstheme.cpp, and at least I've found this snippet here:


enum { // Shell image list ids
sHIL_EXTRALARGE = 0x2, // 48x48 or user-defined
sHIL_JUMBO = 0x4 // 256x256 (Vista or later)
};


So it doesn't seem to be a deliberate omission after all.

d_stranz
28th December 2016, 03:45
The QIcon documentation says that if you ask for an pixmap that is -smaller- than the available sizes and no pixmap of that size has been set, then it will scale a larger pixmap down. However, it will not scale a smaller pixmap into a larger one. So if 32 x 32 is the largest size available, then you'll have to supply your own if you want something larger. If you derive from QFileIconProvider, then you can always do this scaling up yourself instead of having to invent new pixmaps and put them into resources.


the Qt sources, but I don't understand too much of the code there.

You're not the only one with that problem... :)