Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileSystemModel: setting folder icons without using QFileIconProvider
Forum Updated to NodeBB v4.3 + New Features

QFileSystemModel: setting folder icons without using QFileIconProvider

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bubbas
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved