Open external file with parameter
How to execute a binary/executable file with Qt ?
To open a normal file, we can use:
@QUrl url = QUrl::fromLocalFile("file:///Users/paulo/Pessoal/downloads/cpp/poco-doc/110-Logging.pdf");
But i cant pass any parameter, because i get "file not found".
Can anyone help me?
[quote author="prsolucoes" date="1315889693"]How to execute a binary/executable file with Qt?[/quote]
"QProcess":http://doc.qt.nokia.com/latest/qprocess.html is what you are looking for.
QDesktopServices::openUrl() cannot take any parameters. This is logical, as that method does not know which application is used to open the file, that depends on the users preferences. For example, you might want to use a super fast preview program or gimp or photoshop to open an image. Each of that programs does have its own set of command line options (if any!), so it does not make sense to pass those.
The only alternative is to utilize [[Doc:QProcess]], as Lukas suggested. But be aware that you must know which program to use for the file (e.g. Acrobat Reader or some open source application, maybe the Preview.app on the Mac) and probably the path too.
Thanks. This is the solution.