-1

I'm trying to implement a file explorer that will display a list of remote files(stored on another network server). And I use QFileIconProvider.icon(QFileInfo) to get the file icon.

The QFileInfo is constructed from a single filename(no path information):

for example: QFileInfo fi("test.jpg");

and that works on both Windows and Linux(I tested it on a Ubuntu machine), but it doesn't work on the macOS. On macOS, I always get the warning

Path given to -[NSWorkspace iconForFile:] is not a full path.

I have checked the solution here: Qt 4.8 - QFileIconProvider, Getting icon for non-existent file (based on extension), but it's for the Windows platform.

I was able to make it work if I created a temporary file on my working directory with the same remote filename. But the temporary needs to be kept. If I deleted the temporary file after calling QFileIconProvider::Icon, I will get the warning above when the QTableView tries to display the QIcon in the UI.

Is there any working solution for my case?

Thanks all.

MartinZ
  • 175
  • 2
  • 12

1 Answers1

0

Since there is no "correctly" solution, I just make a workaround:

Create a temporary file for each file extension, and keep them here, only delete these temporary files when you ensure you don't need them anymore. (I choose to delete them before my app quit.

At least, it works for me.

Thanks!

MartinZ
  • 175
  • 2
  • 12