In my Qt application, I can save project files of my own type. I would like those files to have a nice preview in Windows explorer, just like picture and video files do by default. Is there a way to do that? I am using Qt, but maybe there is another way.
In other words, if my code for saving a file is as follows, I would like to know what to do in line 5 to make it work:
void saveFile(const QString& fileName, const QImage& thumbnail) {
QFile file(fileName);
file.open(QFile::WriteOnly);
writeInFile(file); // Custom function that saves the project
//file.setPreview(thumbnail); <- What I wish I could simply do
file.close();
}
Setting thumbnail for your own file type is not a Qt thing. It's job of Windows shell, and the behavior is controlled using registery.
Check this if you want to assign a custom icon file.
If you want to generate different preview for each file, just like image file, then check this.
Note they are Windows specific.