PDA

View Full Version : How to open a document with the default application?



SkripT
28th April 2006, 14:41
Hi all, in my app I need to open a document (PDF) with the default application to view this kind of docs in the system. I've tried calling QProcess:start() with the path of the doc but it doesn't works. Could you tell me how to do it? Thanks.

nupul
28th April 2006, 15:04
Hi all, in my app I need to open a document (PDF) with the default application to view this kind of docs in the system. I've tried calling QProcess:start() with the path of the doc but it doesn't works. Could you tell me how to do it? Thanks.

on linux: if you are using KDE give the following

kfmclient exec <filename>

GNOME:
gnome-open <filename>

Cheers

Nupul.

SkripT
28th April 2006, 16:33
on linux: if you are using KDE give the following

kfmclient exec <filename>

GNOME:
gnome-open <filename>

Cheers

Nupul.

Thanks Nupul, but I don't use linux. I'm using Windows XP ;) Moreover, I want to know if there's a general way to make it, without dependency of the operating system, if it's possible.

jpn
28th April 2006, 17:17
Try QDS (http://qds.berlios.de/)'s Launcher service.

SkripT
28th April 2006, 18:01
Thanks jpn, but I think that finally I will make it using QProcess testing the operating system and calling it with the apropiate args like Nupul has comented...

nupul
30th April 2006, 05:41
Thanks Nupul, but I don't use linux. I'm using Windows XP ;) Moreover, I want to know if there's a general way to make it, without dependency of the operating system, if it's possible.

No, there is no way that I can think of to make it OS independent. See Linux uses MIME types to do the bindings with the possible apps that can handle those files. kfclient is used to manage this info of default apps etc....Windows :P may be using some technique similar...I have actually forgotten how to open a file by default app...did it long time ago and am still scouring my head for replies!!! If you ever get the answer to this lemme know too!!

Nupul

Xagen
30th April 2006, 06:52
If you want I can post my class written for Windows to launch default application.

Chicken Blood Machine
30th April 2006, 08:47
Thanks Nupul, but I don't use linux. I'm using Windows XP ;) Moreover, I want to know if there's a general way to make it, without dependency of the operating system, if it's possible.

There's no OS independant way. If you're using windows, use the ShellExecute() function. Check the msdn docs for more info.