Open external file with parameter
-
wrote on 13 Sept 2011, 04:54 last edited by
Hi,
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");
QDesktopServices::openUrl(url);@But i cant pass any parameter, because i get "file not found".
Can anyone help me?
-
wrote on 13 Sept 2011, 05:20 last edited by
[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. -
wrote on 13 Sept 2011, 05:31 last edited by
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.
-
wrote on 13 Sept 2011, 14:48 last edited by
Hi,
Thanks. This is the solution.
Ty.
1/4