Results 1 to 9 of 9

Thread: QProcess - Failed to start

  1. #1
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QProcess - Failed to start

    Hi,

    From my QT application, tried to launch a text file using the following code,

    QProcess *myProcess = new QProcess(this);
    myProcess->start("E:\\temp1.txt", QStringList() << " ", QIODevice::ReadOnly);

    But it says "Failed to start" during execution. Could some one help me to fix this error.

    FYI: Went through all threads, but couldn't find the reason for the above problem.

    Regards,
    Sankar.

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess - Failed to start

    I have never played with QProcess, but looking at the method signature, the first argument to the start method is the *program* and the second argument would be the arguments in the form of a QStringList *to* the program.

  3. #3
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess - Failed to start

    Yes, I agree schnitzel. May be i should give "notepad" application path in first argument i think. But how do we then launch a text file?

    Could you tell me how to launch a text file in read mode from my Qt App.

    Regards,
    Sankar.

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess - Failed to start

    Can you please explain what you want to achieve?
    I don't understand 'launch a text file'.

    Launch the text file in *what*?
    Last edited by schnitzel; 18th March 2011 at 07:10. Reason: clarify

  5. #5
    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 - Failed to start

    Here are some options:
    • You could provide "notepad.exe" as the program and the full path to the text file in the QStringList of arguments.
    • You could use "cmd.exe" as the program and two arguments "/C" and the full path to the file. The lets the shell worry about what application to launch for the provided file.
    • You could use the Windows registry to determine the associated program and launch it.
    • You could have your program allow the user to specify what to open text files with.
    • You could show the file (it is text after all) in a Qt widget and not depend on an external program at all.

  6. #6
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess - Failed to start

    Thanks a lot again Chris.

    Regards,
    Sankar.

  7. #7
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess - Failed to start

    And another option is the QDesktopServices::openUrl
    Last edited by wysota; 21st March 2011 at 11:18.

  8. #8
    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 - Failed to start

    Nice one Rhayader. I've actually used that myself but it completely slipped my mind. This option has the benefit of not being platform specific.

  9. #9
    Join Date
    Feb 2011
    Posts
    36
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess - Failed to start

    Thanks Rhayader. It worked as expected.

    I modified my code to make use of this, since this is platform independent.

    Regards,
    Sankar.

Similar Threads

  1. Replies: 0
    Last Post: 5th October 2010, 15:19
  2. QProcess::start() failed when application runs from sudo
    By alenyashka in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2010, 07:35
  3. QProcess start() failure
    By jacek_ in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2009, 14:04
  4. QProcess to Start App
    By ManuMies in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2009, 12:58
  5. The Gdb process failed to start.
    By been_1990 in forum Qt Tools
    Replies: 3
    Last Post: 29th April 2009, 18:29

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.