QFileSystemModel: setting folder icons without using QFileIconProvider



  • Hi all,

    I'm currently trying to change the folder icons from my FileSystemModelClass (subclass of QFileSystemModel).
    I've tried subclassing the QFileIconProvider but It gave bad performance. Therefore I decided to use the data() method in my FileSystemModelClass instead.

    The problem i face is the following:

    Depending on the contents in a folder, a certain icon for the folder shall be set.

    So, (in theroy), in the data() method I check the user role, and if it is Qt::DecorationRole I return the proper QIcon. Basically, If a folder contains a file with an extension *.foo that folder shall use an icon named "folderFoo" and the data() function shall return the corresponding QIcon.

    So, given a QModelIndex I check if that index is a folder and if so contains a *.foo file and if so, return the "folderFoo" icon.

    But...is does not work. It sets the icons for any folder in the actual folder I want to set the icon for.

    Has anyone done anything like this, and how did you do it?

    Best Regards,
    Bubbas


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.