Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 494
sashoalm Avatar asked Nov 21 '12 14:11

sashoalm


People also ask

How do I change my cursor on QT?

To set a cursor shape use QCursor::setShape() or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the Qt::CursorShape enum.

How do I change my cursor to wait?

We can set the cursor to wait using object. style. cursor = “wait” in javascript.

What does it mean when the mouse pointer appears as an hourglass?

The Windows wait cursor, informally the Blue circle of death (known as the hourglass cursor until Windows Vista) is a cursor that indicates that an application is busy performing an operation.


1 Answers

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.

like image 109
Kamil Klimek Avatar answered Sep 27 '22 22:09

Kamil Klimek