Results 1 to 4 of 4

Thread: QProcess?

  1. #1
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default QProcess?

    Hi all
    i don't know why this code does not run. I want to open C:\PDF_Solution.doc file. But it seems that nothing happend
    pls help me
    thanks

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include<QProcess>
    3. int main(int argc, char *argv[])
    4. {
    5. QCoreApplication a(argc, argv);
    6.  
    7. QProcess Pr;
    8. Pr.start("C:\PDF_Solution.doc",QIODevice::ReadOnly);
    9. Pr.waitForFinished(300);
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2011
    Posts
    44
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: QProcess?

    I guess it should be "C:\\PDF_Solution.doc" instead of "C:\PDF_Solution.doc".
    If it was a typo and corrected code doesn't work anyway then try the following:
    Qt Code:
    1. QDesktopServices::openUrl( QUrl::fromLocalFile( QDir::fromNativeSeparators( "C:\\PDF_Solution.doc" ) ) );
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to llev for this useful post:

    nthung (3rd October 2011)

  4. #3
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess?

    thanks very much, your way is run well
    but, I wonder that why way can't run?
    thanks

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QProcess?

    "C:\\PDF_Solution.doc" is not a Windows executable file. The Windows API CreateProcess call that Qt ultimately uses expects an executable. The file type association magic you are expecting to happen is managed by the Windows shell (and by extension by QDesktopServices).

Similar Threads

  1. Replies: 0
    Last Post: 26th August 2010, 10:44
  2. Trying to use QProcess
    By hybrid_snyper in forum Newbie
    Replies: 7
    Last Post: 20th October 2009, 14:55
  3. Help with QProcess!!
    By afflictedd2 in forum Qt Programming
    Replies: 4
    Last Post: 28th March 2009, 22:56
  4. QProcess inside QProcess
    By bunjee in forum Qt Programming
    Replies: 7
    Last Post: 4th December 2008, 00:39
  5. QProcess in qt-2.3
    By winarko in forum Qt for Embedded and Mobile
    Replies: 7
    Last Post: 2nd July 2008, 21:58

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.