I have created HTML help for my app (using the Helpinator product). I use this code to fir it off from a menu action:
void MainWindow::onHelpUserManual()
{
if ( result < 0 )
QMessageBox::warning( this,
"Command failed",
"Could not open user manual. Please open it using the Windows Start menu instead." );
}
void MainWindow::onHelpUserManual()
{
QString helpIndexUrl = QCoreApplication::applicationDirPath() + "/htmlhelp/index.html";
int result = QProcess::execute( "cmd.exe", QStringList() << "/c" << helpIndexUrl );
if ( result < 0 )
QMessageBox::warning( this, "Command failed", "Could not open user manual. Please open it using the Windows Start menu instead." );
}
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.
Bookmarks