Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Read filetype info from file
cheops last edited by cheops
I use QFileInfo to read some information directly from the file, like date/time of creation, last saved etc... This works really simple, but I wonder, how it is possible to get also information about the type of file. If you rightclick a file in the explorer and open the properties window, you can see infos about the filetype, like "Libre Writer Document" or "Gimp Picture" ... Is this info stored in the file itself, and when yes, is there a way to read out this info?
Thanks in advance,
Is this info stored in the file itself,
No. It's saved system wide. And it's desktop environment specific. So Gnome will save the associations in one place, KDE in another, Windows has its own handling.
is there a way to read out this info?
Probably, but it'd be tied to the system and you have to code it manually for each supported OS.
A Former User last edited by A Former User
Strictly speaking there is nothing such as a filetype. A file is a file. But depending on the content you'll want the file to be viewed / modified / whatever with this or that application. That's what file extensions on MS DOS were invented for; to help the OS to choose the right application to open a particular file. On other systems, such as Linux, file extensions can be used but aren't mandatory. On such systems there are additional mechanisms in place to determine the right application. E.g. some file formats use a magic number in the first bytes.
cheops last edited by
@Wieland Thanks for the explanation!