Streight
Streight

Reputation: 861

Why does the window not pop up?

I have the following source code:

    Processmethod()
{

    QDialog *ProcessMessage = new QDialog;      
    Ui::DialogProcessMessage Dialog;            
    Dialog.setupUi(ProcessMessage);             
    ProcessMessage->setModal(true);
    ProcessMessage->setAttribute(Qt::WA_DeleteOnClose); 
    ProcessMessage->show();



    PROCESSES START                     
}

After I want to show the QDialog "ProcessMessage" there are three QProcess processes included in three different following methods. If I disable these methods with // the popup window appears just fine, but if I enable the methods, the processes run fine, but the popup window does not appear. Any ideas/solutions ? greetings

Upvotes: 0

Views: 256

Answers (2)

Your window do not show until Process method is not return because main application loop implemented in main function

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);
        QDialog w; // or other window
        w.show();
        return a.exec(); // main app loop (all drawing procedures called from here
}

So if you call your PROCESSES START nothing happened until Process method returns in QApplication::exec()

You can start your processes in separate thread and send progress notification to you dialog by implementing signals\slots in queued mode

Upvotes: 2

Arnold Spence
Arnold Spence

Reputation: 22282

The dialog cannot be shown until your code execution exits ProcessMethod(). If you are using the QProcesses synchronously (by calling any of the waitForXXX methods), then this would cause the problem you are seeing. Anything else that holds up the main thread would also cause this problem.

Upvotes: 1

Related Questions