简体   繁体   中英

qt wait for signal/event, GUI

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!

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();
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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