Results 1 to 4 of 4

Thread: How to detach a QProcess?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default How to detach a QProcess?

    I have created HTML help for my app (using the Helpinator product). I use this code to fir it off from a menu action:

    Qt Code:
    1. void MainWindow::onHelpUserManual()
    2. {
    3. QString helpIndexUrl = QCoreApplication::applicationDirPath() + "/htmlhelp/index.html";
    4. int result = QProcess::execute( "cmd.exe", QStringList() << "/c" << helpIndexUrl );
    5. if ( result < 0 )
    6. QMessageBox::warning( this, "Command failed", "Could not open user manual. Please open it using the Windows Start menu instead." );
    7. }
    To copy to clipboard, switch view to plain text mode 

    This works fine - if my browser (Firefox) is running, it opens a new tab and loads the help file into it. If it isn't running, it starts the browser and loads the help file.

    The problem is this: In the first case (browser already running), the call to QProcess::execute() returns immediately. In the second case (browser not running), the execute call does not return and so the program is frozen until I exit the browser.

    (Pause while I close the browser and test QProcess::startDetached())

    startDetached() does not work either. Bizarre behavior - in a debug build, startDetached() will run up a command window, which then starts the browser. In a release build, startDetached() results in a quick flash of the command window, then nothing. Doesn't matter whether the browser is running or not.

    How do I do this? I am at a loss to explain what I am observing.
    Last edited by d_stranz; 28th August 2015 at 00:58.

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Finding QwtPlot child item to detach it
    By Momergil in forum Qwt
    Replies: 2
    Last Post: 16th January 2013, 19:01
  3. how to detach Tab page from QTabWidget?
    By rajesh in forum Newbie
    Replies: 3
    Last Post: 30th May 2012, 16:20
  4. Replies: 1
    Last Post: 13th July 2011, 08:55
  5. detach only one qwt plot curve?
    By kja in forum Qwt
    Replies: 1
    Last Post: 3rd December 2010, 07:54

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
  •  
Qt is a trademark of The Qt Company.