Reputation: 319
I am working on an Qt application which has the possability to use a script to perform several actions. One command within the script requires an external event to happen until the next command in the list can be computed (which is not the case for the rest of the commands).
Usually, I open the file, read a line of the script and process it. This is repeated until the EOF is reached.
Emitting a signal when the external event occured is possible, but the function which runs through the script hast so to be stopped during this timespan.
How can i archive this whithout locking the GUI response?
Thank you!
Upvotes: 1
Views: 737
Reputation: 40502
I would do it this way:
public:
void execute_script() {
//open file
continue_execution();
}
public slots:
void continue_execution() {
while(!file.atEnd()) {
//read and process command
if(async_command) {
//make sure the signal indicating command completion
//is connected to continue_execution() slot
return;
}
}
emit script_finished();
}
Upvotes: 1