PDA

View Full Version : How to load file when program opens



TomJoad
10th April 2011, 21:47
I created a unique file extension, and I want the user to be able double click on their saved file and the program automatically opens and loads it. How do I do that?

I imagine this would use the argv value in main? But I have no idea how it would be done.

Zlatomir
10th April 2011, 21:57
The file extension you must "register" from the OS to open with your program (i don't know how you can done this from your application - maybe the installers have some options for that, since the installer knows where the user installs your application) and then the double clicked file name (and path) will be sent by the OS using the arguments (int argc is the number of arguments and char** argv are the argument strings, also QCoreApplication has functionality that returns arguments (http://doc.qt.nokia.com/latest/qcoreapplication.html#arguments) in a QStringList (the first argument is the exe name and path).