PDA

View Full Version : What is the best way to wait for a response from another application?



agerlach
12th October 2010, 20:00
I am building an application for my graduate research that processes 3D scans of real-world objects, but unfortunately the scanning software required to control the scanning hardware is proprietary and it has no SDK or way to control it from the command line.

The application I am building is basically a wizard that walks the user through setting some parameters for post-processing the scan, then calls the external scanning software using QDesktopServices. I would like my application to monitor a folder and then return control and load the file saved to that folder by the 3rd party software. I am able to monitor the folder using QSystemFileWatcher which issues a SIGNAL once a file is modified in the directory.

My question is what is the best way to have my application wait in the background until a file is saved? My first thought was to have a while loop with a sleep() and processEvents() call. The SLOT called by the QSystemFileWatcher would then break the while loop. I think this would work but I just thought somebody would know a better way on how to approach this.

Thanks.

squidge
12th October 2010, 22:38
All Qt applications run at least one event loop, so just wait for the signal. No need to use a while loop, sleep calls or processEvents.