I'm writing a program that enables the WLAN drivers on a device, and then searches for local Wi-Fi connections. Turning on the drivers and performing the scan are done using the command line with QProcess. This all works fine; the problem is that I try to update the UI before the scan happens, to let the user know what is happening. Here's the code:
ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
ui->toolButton->setText("Searching, please wait...");
// Enable WLAN drivers
QProcess process;
process.start(turn on WLAN);
process.waitForFinished();
// Get WLAN information for available networks
process.start("iwlist wlan0 scan"); // Find wireless access points
process.waitForFinished();
QString wirelessInfo = process.readAll();
Simply put, the user presses a button to start the scan, and I want the button to change text to say "Searching, please wait..." before the scan starts, since it takes a few seconds for the scan to finish.
However, the UI doesn't update before the scan starts. The system simply appears locked up for a few seconds, then moves on to the rest of the program (which brings up a separate window with the Wi-Fi info). I tried getting the thread to sleep for a few seconds between the button text change and the scan, but the result is the same. Is there a reason that the text won't update before the scan begins, even though the scan is after the setText command in the code?
If it helps, I'm running Qt 4.8.4 in Qt Creator using Ubuntu.