Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an operating system independent way to open file with associated program from C++?

What is an operating system independent way to open a file with associated program from C++? Is there a solution in Boost, or something like it?

More specifically, something that would cover Windows, Mac OS X, and Linux.

What I am trying to do is open a file ending in the .txt extension in the program that the user already has set up to open it if they were to open it themselves via clicking it or command line.

The mechanism needs to be asynchronous.

like image 273
blu3isotope Avatar asked Mar 21 '11 00:03

blu3isotope


2 Answers

QDesktopServices::openUrl from Qt library provides this. It is asynchronous (non-blocking).

like image 142
Tugrul Ates Avatar answered Sep 28 '22 00:09

Tugrul Ates


Just calling the name of the data file with system() should work on any OS that supports typing the filename on the command line

like image 35
Martin Beckett Avatar answered Sep 28 '22 02:09

Martin Beckett