Open a File from Explorer in my Qt application
-
wrote on 26 Apr 2020, 08:26 last edited by aha_1980
Hi,
My application is writing files. I would like to open such a file in my application, if it is clicked on in the Windows explorer. For this, I think once I have to set open with to my application. If I understand it correctly, my application is then called with the file name as argument.
Is it also possible to open a file in an already running instance of my application (it is possible to have several files open at once)
Thanks!
-
You could take a look at QtSingleApplication
-
wrote on 26 Apr 2020, 17:25 last edited by
Ok, interesting. Still, how could I load a file in my running application via a click on a file in the Windows explorer? Is there a slot which gets called automatically?
-
Hi,
If you mean associate your application with your custom file type then you have to configure your OS for that.
-
wrote on 26 Apr 2020, 18:31 last edited by
Hi SGaist,
Yes, thats what I mean. But once I have associated a file type with my application, what happens next? Does e.g. Windows (which will be the main target platform, although we also support Linux) simply call my application executable (and gives it the file name as argument?) or is there a more complicated mechanism?
-
wrote on 26 Apr 2020, 18:33 last edited by SGaist
Now that I know its called associating I found this:
https://wiki.qt.io/Assigning_a_file_type_to_an_Application_on_Windows -
Nice ! Thanks for sharing your finding !
1/7