I am attempting to add a folder icon for the folder items in my directory, along with the icons for the associated file type.
iconProvider = QFileIconProvider()
for item in os.listdir(path):
QItem = QStandardItem(item)
file_item_icon = iconProvider.icon(QFileInfo(item))
QItem.setIcon(file_item_icon)
root_item.appendRow(QItem)
QTreeView Where folders show up with a White Icon

I have tried using the QFileSystemModel which does correctly show the icons, However, I need the control the QStandardItemModel offers...
QTreeView where icons are working

If the path used to construct the QFileInfo instance is not absolute, it can only use relative paths. As the documentation explains:
[emphasis mine]
os.listdir()returns only the names:This means that QFileInfo will only have a "relative" name of each entry based on the working directory.
This is clearly an issue in your case:
os.listdir()coincides with an existing name of the working directory, it could even provide the wrong icon: suppose you have asomething.docfile in the working dir and the name returned byos.listdir()also issomething.doc, it will have the icon of the former file, even if the latter is actually a directory;So, the solution is to use absolute paths or the proper icon type.
For simple cases (when the icon type is known), you can use the
icon(IconType)override using the provided enum. For instance, if you do know that the path refers to a directory (i.e.os.path.isdir()):Otherwise, you should use the full path, so that QFileInfo will use the real file reference: