2 works, thanks!
But why 1 icon isNull() ?
Is possible 1 and 2 under Linux? Linux has something like mime or/and Elf binaries can holds icons?
Bad:
QPixmap extractMime(const QString &sourceFile)
{
QMimeDatabase mime_database;
const QString nativeName = QDir::toNativeSeparators(sourceFile);
QIcon icon;
QList<QMimeType> mime_types = mime_database.mimeTypesForFileName(nativeName);
icon = QIcon::fromTheme(mime_types[0].iconName());
if (icon.isNull()) qDebug() << "null";
qDebug() << mime_types[0].iconName();
return icon.pixmap(16);
}
Maybe this work for Linux, but for Windows I need registers. Sample C# application https://www.codeproject.com/Articles/29137/Get-Registered-File-Types-and-Their-Associated-Ico
for example:
Computer\HKEY_CLASSES_ROOT.mp3 has
OpenWithProgIds/WMP11.AssocFile.MP3
Computer\HKEY_CLASSES_ROOT\WMP11.AssocFile.MP3 has DefaultIcon = %SystemRoot%\system32\wmploc.dll,-732
wmploc.dll is resources and 732 index of icon?