简体   繁体   中英

I have a GUI for my program that saves a config file, how can I double click on this config file to load the GUI directly with the config data?

So I have this program written in C++, and I created a GUI application (using Qt5) for it that runs on Windows. On the GUI, you can enter some data (for eg Name, Age, Date,...). With this data some processing can be done.

The GUI is able to serialize and save the data I entered (Name, Age, Date..) into a binary or text file (or basically anything). The GUI can also load this config file with this data.

However, what I want is that wherever I save this config file, I want to be able to double-click on this config file and it should link to the GUI application to run, and of course display the data that was saved in the config file.

So my question is what tools/considerations do I need to get this feature (at least on Windows)?

There is probably more than one way to implement this feature. Here is what I would do:

  • Make a unique file type for the config file (a dot extension like.myappconf or something like that should do it)
  • Create a file association for your application with that file type. This is typically done in the installer or in the.desktop file when you are on Linux.
  • Now with this association the action of double clicking the file will trigger your Operating System to run a new copy of your app and present it with the config file (via a command line argument).
  • The application should check on startup if there is already a copy of it running. If so, it should send a notification about the config file to the old copy and then self-terminate.

Note: If you are okay with the double click action starting up a new copy instead of loading the file into the old one (if any), you can skip the last step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM