[SOLVED] Can`t send data to QProcess

  • Im trying to create an app, which can compile and run some simple cpp progs, so I need to write an output to textEdit and read input from lineEdit. The code below compiles, but the data isnt sending to the process corectly (nothing happends).
    @void MainWindow::on_lineEdit_returnPressed()// input from lineEdit
    void MainWindow::on_action_24_triggered()
    // The code below compiles and runs the prog from textEdit
    QString str = tabs[cur_tab]->toPlainText();
    QFile file("temp.cpp");
    file.open(QIODevice::Append | QIODevice::Text);
    QTextStream out(&file);
    out << str;
    out << "\n";
    cp->start(("g++ temp.cpp"));
    if (!QFile::exists("a.exe"))
    qDebug() << "Error";
    //Another trouble here
    //cp->waitForFinished(); //<-If not commented then the programm crashes
    //QFile("a.exe").remove(); // And the file cant be removed, because is still running } }@ The main problem is that the data cant reach the process, I dont know why. Therere no warns or errors that are displayed.
    P.S. Sorry for my english!http://postimage.org/image/4sk3ru0wh/(Screenshot of my UI)!

  • Though not look into it, I think you may want to try QProcess::readAllStandardOutput() or QProcess::readAllStandardError() for details.

  • The problem has been solved - you need to send "\n" at the end of input.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.