Results 1 to 5 of 5

Thread: Open File /w Native Application

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Open File /w Native Application

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Thanked 8 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open File /w Native Application

    With Qt 4.2, you can try QDesktopServices:

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

    Bojan
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Open File /w Native Application

    Quote Originally Posted by bpetty
    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

  4. #4
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open File /w Native Application

    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.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Open File /w Native Application

    Quote Originally Posted by bpetty View Post
    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. See especially post #6 by wysota (there's an example for you).
    J-P Nurmi

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  2. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  3. Application build Mac PPC/Intel pro file?
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 28th June 2006, 13:27
  4. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 14:16
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.