Get file type/extension's friendly name?
-
Its returning "Word 2007 Document", whereas Windows Explorer shows "Microsoft Word Document".
I didn't really understand the part about qt qmake Profile, does it mean that I can provide my own database for QMimeDatabase to use?
Isn't there a Qt API that calls respective OS api to get File info e.g. SHGetFileInfo on windows?
@Taytoo said in Get file type/extension's friendly name?:
Isn't there a Qt API that calls respective OS api to get File info e.g. SHGetFileInfo on windows?
I think the simple answer to answer is "no". Qt tries to be cross-platform. You are asking for a Windows-specific.
You can make the call yourself via Win API.
Or, if you don't like what Qt is returning now, you have to re-read https://doc.qt.io/qt-5/qmimedatabase.html#details section
Applications which want to define custom MIME types need to install an XML file into the locations searched for MIME definitions.
You would have to produce an XML file like the example but for your
docx
with thecomment
you want, and then put it in one the directories returned from theQStandardPaths::locateAll()
call they show, whatever those turn out to be under Windows. That is assuming your file there will override the Qt-supplied one fordocx
which you have shown, the docs don't say whether your definition fordocx
would indeed override the in-builts. -
How can I get friendly name for a given file extension e.g. temp.docx = "Microsoft Word Document"
QMimeDatabase::preferredsuffix() just returns "docx"
@Taytoo
Unless you want something more non-Qt-Windows-specific, I think you want https://doc.qt.io/qt-5/qmimetype.html#comment-prop. From the example at https://doc.qt.io/qt-5/qmimedatabase.html#details I see<mime-type type="application/vnd.qt.qmakeprofile"> <comment xml:lang="en">Qt qmake Profile</comment> <glob pattern="*.pro" weight="50"/> </mime-type>
so that should give you
Qt qmake Profile
, which is as good as it gets. Read that section; note also if you are Windows:If the MIME type database cannot be found on the system, as is the case on most Windows, macOS, and iOS systems, Qt will use its own copy of it.
You'll have to see what that gives you for
.docx
... -
Its returning "Word 2007 Document", whereas Windows Explorer shows "Microsoft Word Document".
I didn't really understand the part about qt qmake Profile, does it mean that I can provide my own database for QMimeDatabase to use?
Isn't there a Qt API that calls respective OS api to get File info e.g. SHGetFileInfo on windows?
-
Its returning "Word 2007 Document", whereas Windows Explorer shows "Microsoft Word Document".
I didn't really understand the part about qt qmake Profile, does it mean that I can provide my own database for QMimeDatabase to use?
Isn't there a Qt API that calls respective OS api to get File info e.g. SHGetFileInfo on windows?
@Taytoo said in Get file type/extension's friendly name?:
Isn't there a Qt API that calls respective OS api to get File info e.g. SHGetFileInfo on windows?
I think the simple answer to answer is "no". Qt tries to be cross-platform. You are asking for a Windows-specific.
You can make the call yourself via Win API.
Or, if you don't like what Qt is returning now, you have to re-read https://doc.qt.io/qt-5/qmimedatabase.html#details section
Applications which want to define custom MIME types need to install an XML file into the locations searched for MIME definitions.
You would have to produce an XML file like the example but for your
docx
with thecomment
you want, and then put it in one the directories returned from theQStandardPaths::locateAll()
call they show, whatever those turn out to be under Windows. That is assuming your file there will override the Qt-supplied one fordocx
which you have shown, the docs don't say whether your definition fordocx
would indeed override the in-builts.