Question

I am unable to get QProcess to read any output from my VBScript. The script executes both on its own and when called from QProcess, and outputs to QCreator's Application Output, so I know my VBS is executing. To troubleshoot I've cut my VBS down to:

WScript.StdOut.WriteLine("Hi")

Qt-side I've tried:

  • Connecting QProcess's finished, readyReadStandardOutput, readyReadStandardError signals
  • I have also tried setProcessChannelMode to QProcess::MergedChannels

In the MainWindow constructor:

connect(Process,SIGNAL(readyReadStandardOutput()),this,SLOT(processDone()));

Slots:

void MainWindow::processDone()
{
qDebug()<<"Out";
/*QString str;
str.append(Process->readAllStandardOutput());
qDebug()<<str;*/
}


void MainWindow::runProcess()
{
    QString script = "cscript";
    QStringList args;
    args<<QString(QDir::currentPath()+ "/myVBs.vbs")<<"//NoLogo";
    Process->execute(script,args);
}
Was it helpful?

Solution

QProcess::execute is a static method, so Process->execute(script, args) is equivalent to QProcess::execute(script, args), i.e. your instance Process isn't used at all. Use

Process->start( script, args );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top