PDA

View Full Version : Open File /w Native Application



bpetty
11th August 2006, 16:50
I just started developing under QT 4.1 so I am pretty new to the classes.
Is there a simple way to open a file with its native application.
I know about QProcess, but I don't think that is what I want.

Example:
I have an .xml file called ErrorLog.xml. I want to open that error log with what ever the default .xml reader is. How would I go about this?

Thanks for the help!

Brandon P.

Bojan
11th August 2006, 19:22
With Qt 4.2, you can try QDesktopServices:

http://doc.trolltech.com/4.2/qdesktopservices.html

Bojan

Brandybuck
11th August 2006, 19:45
I just started developing under QT 4.1 so I am pretty new to the classes.
Is there a simple way to open a file with its native application.
I know about QProcess, but I don't think that is what I want.

Example:
I have an .xml file called ErrorLog.xml. I want to open that error log with what ever the default .xml reader is. How would I go about this?

Thanks for the help!
Qt 4.2 will have functionality for this. Read more at http://doc.trolltech.com/4.2/qdesktopservices.html

bpetty
27th October 2006, 21:53
I guess I don't understand how QDesktopServices accomplishes this.
It appears to be a web oriented thing... all I want is to open a file, like test.txt, in notepad under windows or kate under linux... if that is their native viewer.

or open a .pdf in what ever they have set to open .pdf's. I dont see how this is accomplished with the URL system QDesktopServices uses.

Does anyone have an example of how to open a file /w the native "viewer" using QDesktopServices? Maybe I just don't see it.

Thanks,
Brandon P.

jpn
27th October 2006, 22:19
I guess I don't understand how QDesktopServices accomplishes this.
It appears to be a web oriented thing... all I want is to open a file, like test.txt, in notepad under windows or kate under linux... if that is their native viewer.

or open a .pdf in what ever they have set to open .pdf's. I dont see how this is accomplished with the URL system QDesktopServices uses.

Does anyone have an example of how to open a file /w the native "viewer" using QDesktopServices? Maybe I just don't see it.
Something pretty much the same was just recently discussed in this thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qdesktopservices-open-url-local-file-pdf-or-doc-4178.html). See especially post #6 by wysota (there's an example for you).