Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Qt and fork()

$
0
0
I want to write some wrapper to console app. The problem is I cant understand why label_2 isn’t changed to “Wait” till converter is done working. I think the main process should change it’s text to “Wait” and then split by fork(), wait till converted is done and then change labet’s text to “done”. Form::Form(QWidget* parent){     setupUi(this);     connect(pushButton, SIGNAL(clicked()), this, SLOT(generate()));         this->tmpFilename = "word_list.txt"; }   void Form::generate(){     label_2->setText("Wait!");     pid_t PID = fork();         if(PID == 0){         QFile file(this->tmpFilename);         file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text);         QTextStream fileStream(&file);         fileStream << plainTextEdit->toPlainText();         file.close();                 execl("./converter", "converter", this->tmpFilename, NULL);         exit(0);             } else if(PID > 0){         wait(NULL);         label_2->setText("Done!");     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles