Using relative paths for resources in Qt

In a current project I wanted to use custom icons for a QTreeView using a stylesheet. I have done this before but then I used rcc to compile the resources. This works fine but in this case I wanted to use the icons without compiling them. I did this mainly for learning how to do it and to not having to complie the resources everytime I change something during the dev phase. I tried a number of ways to use a relative paths in the stylesheet but nothing worked. I tried with an absolute path to the icons which worked fine. I also tried to format the stylesheet string inserting the path to the current directory which worked fine but looked and felt like a bad idea. So after some googling I found the QDir class.

QDir class

In the Qt docs we can read: The QDir class provides access to directory structures and their contents. A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt’s resource system.

So what I did was to use setSearchPaths(prefix, searchPaths) to point the prefix to the dir containing my icons and in the stylesheet use that prefix.

QtCore.QDir.setSearchPaths("icons", [os.path.dirname(os.path.abspath(__file__)) + "/icons"])

Example from the style sheet:

QTreeView::indicator:checked {
    image: url(icons:cb-checked.png);

If you have some feedback or ideas on how to improve this workflow please let me know.