Results 1 to 6 of 6

Thread: How to start a process(application) on windows? (solved)

  1. #1
    Join Date
    Feb 2010
    Location
    Hungary
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation How to start a process(application) on windows? (solved)

    Hi!

    I wrote a small code on linux, what start a firefox browser, it works on ubuntu, but I tried it on windows, and it doesn't work.

    The code:
    QProcess process;
    process.start("firefox"); //I also tried process.start("C:/Program Files/Mozilla Firefox/firefox.exe");

    Can somebody help me?

    Regards,
    Sutee84
    Last edited by sutee84; 13th March 2010 at 15:04.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to start a process(application) on windows?

    Are you sure the path is correct? Try typing it into the Start->Run box first.

    Secondly, a string like C:\ProgramFiles\Mozilla-firefox\firefox.exe wil never work, as \ is an escape character. Try C:\\ProgramFiles\\Mozilla-firefox\\firefox.exe instead.

    Or, if opening a web page is your goal, just pass the web page url to the os, and the default browser will be opened.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to start a process(application) on windows?

    Does "C:/Program Files/Mozilla Firefox/firefox.exe" really exist on your computer? You can try backslashes, but I don't think that's an issue here. Try use QProcess::execute().

    EDIT: Too late...
    EDIT: For the last paragraph of fatjuicymole see QDesktopServices.

  4. #4
    Join Date
    Feb 2010
    Location
    Hungary
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to start a process(application) on windows?

    Yes the path is good, because I get it with QFileDialog, and store it in a QString, but I think, the problem is with the QString, but I don't know, how can I remove the spaces from the QString.

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to start a process(application) on windows?

    What spaces? They are part of the path. YOu can't remove them. But use QString::trimmed() and QDir::toNativeSeparators(). This might help.

  6. #6
    Join Date
    Feb 2010
    Location
    Hungary
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to start a process(application) on windows?

    I solved the problem:
    ffpath.replace("\/","\\");
    process.start("\""+ffpath+"\"");

    And it works!
    Thx!

Similar Threads

  1. Start application when OS starts
    By sophister in forum Qt Programming
    Replies: 16
    Last Post: 13th April 2011, 07:38
  2. Replies: 3
    Last Post: 6th January 2010, 17:55
  3. How to start external application from QT?
    By TomASS in forum Newbie
    Replies: 10
    Last Post: 7th November 2009, 18:57
  4. The Gdb process failed to start.
    By been_1990 in forum Qt Tools
    Replies: 3
    Last Post: 29th April 2009, 18:29
  5. Start Qt application as Windows Service
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 10th May 2008, 18:23

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.