0

I am creating an application using Qt. The files saved from my application have their own file format & extension. I want to associate this file format with my application. So, when a user double clicks say myfile.ext then the OS should automatically run my application (how to specify its path?) & pass path of file as an argument.

I have only used Windows until now so I am talking in terms of it. I dont know how other OS's behave. Any guidance for the same would be helpful?

PS: Even though I am using Qt which apparently has no special functionality to do what is asked here (AFAIK), it would be awesome to know how to do this in standard C++.

4

2 回答 2

2

For Windows see the MSDN page "File Type Handlers" for how to register file type handlers.

On many popular Linux desktops, so-called .desktop files are used to define what application to use for opening a file. See the "Desktop Entry Specification" for the structure of those .desktop files. They are quite simple really, changes are you can just take an existing file from any of the popular Linux desktop environments (e.g. KDE) and modify it a bit.

于 2013-07-02T12:09:50.263 回答
1

它是操作系统的功能,而不是 C++ 语言的功能。您需要在您支持的每个平台上弄清楚。

于 2013-07-02T12:01:21.740 回答