简体   繁体   English

Qt程序每次都会冻结

[英]Qt program freezes every time

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. 我正在使用qtcreator在Qt中制作一个C ++ GUI程序,但尚未完成,但是每当我构建并运行以测试该程序是否运行时,如果我单击打开文件或在文件中写入内容的按钮,该按钮就会执行此操作,并且然后程序冻结。 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);
}

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 . 如果您不想这样做,请使用startstartDetached方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM