PDA

View Full Version : System File Association



johnmauer
9th July 2010, 03:34
Is there a programmatic way to associate a file extension with the application? Then the user could double-click the file name to start the app with that file. I understand that it can be done in the install program, but I would like to do it within the code. Thanks.

suslik
9th July 2010, 05:24
What you're asking for is OS-specific, and not really a Qt question. The OS has to know to start one app or another. If you're packaging your program for Linux, you usually want to include the file association in a post-install script of your package.

Have a look at Wikipedia http://en.wikipedia.org/wiki/File_association to start :).

johnmauer
9th July 2010, 12:48
Thanks. Yes, I know that the associations are OS specific, but much of Qt is designed to make OS specific code disappear. I was hoping that this deployment detail had been considered in code, so that the relevant files/registrations could be handled directly. I suppose not.

squidge
9th July 2010, 14:06
Typically, the job of associating applications with extensions is done by the OS-specific installer of your application, not your application itself.

Vadim
10th November 2010, 22:25
What you're asking for is OS-specific, and not really a Qt question. The OS has to know to start one app or another. If you're packaging your program for Linux, you usually want to include the file association in a post-install script of your package.

Have a look at Wikipedia http://en.wikipedia.org/wiki/File_association to start :).

I thought that the sole purpose of Qt is to handle "OS-specific" issues.
Currently a developer has to go through a lot of pain implementing it himself. It is relativaly straightforward on Windows but Linux is a mess. For example Gnome 2.2 is very different from Gnome 2.8 implementation.
And no, it is not the installer only issue. It might be if the application handles a single file extension.
Many applications that handle multiple file associations allow the user to change the settings.

johnmauer
10th November 2010, 23:35
Exactly, but this detail is not as interesting as others, and so is unlikely to get support. We probably need to volunteer.