Change cursor to hourglass/wait/busy cursor and back in Qt

sashoalm picture sashoalm · Nov 21, 2012 · Viewed 42.3k times · Source

I spawn a process that performs a lengthy operation, and I'd like to give visual feedback that something is happening, so I want to change the cursor to busy and restore it when I receive the QProcess::finished signal.

Answer

Kamil Klimek picture Kamil Klimek · Nov 21, 2012

Qsiris solution is "widget wide". If you want to change cursor for your whole application then use

QApplication::setOverrideCursor(Qt::WaitCursor);

and

QApplication::restoreOverrideCursor();

Note: As @Ehsan Khodarahmi pointed out, the cursor will NOT change until triggering next QT event or calling QApplication::processEvents() manually.