Results 1 to 8 of 8

Thread: QFileIconProvider: available sizes only up to 32x32?

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QFileIconProvider: available sizes only up to 32x32?

    Hi,
    I am using the QFileIconProvider this way:

    Qt Code:
    1. QFileInfo info = QFileInfo(myFileName);
    2. QIcon icon = provider.icon(info);
    3. qDebug()<<"availableSizes: "<<icon.availableSizes();
    To copy to clipboard, switch view to plain text mode 
    (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?
    Last edited by sedi; 26th December 2016 at 17:09.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,249
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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?

  4. #4
    Join Date
    Dec 2016
    Location
    New England, US
    Posts
    31
    Thanks
    6
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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.

  5. #5
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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.
    Last edited by sedi; 27th December 2016 at 19:44.

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,249
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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:
    Qt Code:
    1. enum { // Shell image list ids
    2. sHIL_EXTRALARGE = 0x2, // 48x48 or user-defined
    3. sHIL_JUMBO = 0x4 // 256x256 (Vista or later)
    4. };
    To copy to clipboard, switch view to plain text mode 

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

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,249
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileIconProvider: available sizes only up to 32x32?

    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...
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QFileIconProvider and QFileDialog
    By hakermania in forum Newbie
    Replies: 1
    Last Post: 27th October 2011, 19:45
  2. QFileIconProvider problem
    By rittchat in forum Qt Programming
    Replies: 5
    Last Post: 29th November 2010, 05:02
  3. Getting mulitiple size file icons with QFileIconProvider
    By gmat4321 in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2009, 14:41
  4. Replies: 4
    Last Post: 7th January 2009, 11:13
  5. Replies: 9
    Last Post: 29th March 2007, 14:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.