Unsolved Setting a filetype association with the application the Qt way?
Perdrix last edited by
Windows code currently makes entries in the Windows Registry HKEY_CLASSES_ROOT to associate a particular file extension with my application. Is there a Qt way to achieve this in a platform independent manner?
JonB last edited by JonB
I don't think Qt has this, because it's so OS specific, and for Linux at least I'm not sure what it means. For Windows the wiki offers code at https://wiki.qt.io/Assigning_a_file_type_to_an_Application_on_Windows. Actually a lot of that code looks rather old to me.
Windows code currently makes entries in the Windows Registry HKEY_CLASSES_ROOT
Yes, but doesn't this require elevated permission? Usually this is done from an installer running with privileges?
I have to agree with @JonB. Qt does not provide anything as this is specific to the operating system. Also, he is right that it should be done by the installer (on most platforms).
On Windows you have to set entries in the registry. You seem to have that figured out already.
For Linux we are using
xdg-mime install ...to register file extensions and
xdg-mime default MyApp.desktop ...to associate the file extensions with MyApp. In most Linux file explorers this should work as expected. Also, you can use
xdg-open [filename]to use this information on the command line.
macOS usually does not use an installer. Hence, this information needs to be entered into a
.plistfile which resides in the application folder. This will automagically register the file extensions with the software when placed in the Applications folder.