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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
Use this to set the cursor to wait when the process begins:
this->setCursor(Qt::WaitCursor);
And this to restore the cursor back to normal (put this in the slot for QProcess::finished)
this->setCursor(Qt::ArrowCursor);