Frage

I'm making a C++ GUI program in Qt using qtcreator its not complete yet but when ever I build and run to test the program it runs then if i click buttons that open a file or write something in a file, the button does that and then the program freezes. Why this happens, What I'm doing wrong or what's the issue.

It mainly freezes in theses two functions:

    void MainWindow::on_kmpOpenButton_clicked()
{
    QString kmplayerloc = "\"F:\\Program Files\\The KMPlayer\\KMPlayer.exe\"";
    QProcess::execute(kmplayerloc);
}

void MainWindow::on_nbopenbutton_clicked()
{
    // Remember tha if you have to insert " in a string  \"....location of file or anything u want to put.......\"
    QString netbeansloc = "\"F:\\Program Files\\NetBeans 7.4\\bin\\netbeans.exe\"";
    QProcess::execute(netbeansloc);
}
War es hilfreich?

Lösung

From the documentation

Starts the program program [..] in a new process, waits for it to finish, and then returns the exit code of the process.

The calling thread freezes until the external process is finished. If you don't want this, use the method start or startDetached.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top