PDA

View Full Version : Cursor not changing



bpetty
16th July 2007, 18:13
I have a class that inherits from QMainWindow called CMainForm.

I have a menu action that triggers a method called menuPackageLogs().

At the begining of the method I set the cursor to Qt::WaitCursor, and at the end I set it back to Qt::ArrowCursor. In between I call a routine that blocks for a while. The problem is that my cursor never changes. It is always an arrow, never an hour glass.

I must be missing something fundemental here.
Here is an example of the method that gets called:



void CMainForm::menuPackageLogs()
{
// Change cursor to wait cursor
setCursor(QCursor(Qt::WaitCursor));

bool bRet = UpgradeUtils::PackageLogs();

// Change cursor back to standard arrow
setCursor(QCursor(Qt::ArrowCursor));

if (bRet == true)
{
QMessageBox::warning(this, tr("Package Logs"),
"Upgrade log files successfully packaged.");
}
else
{
QMessageBox::warning(this, tr("Package Logs"),
"Could not package Upgrade log files.");
}
}


If anyone has any ideas, I am all ears. Thanks.

marcel
16th July 2007, 18:40
Are you sure this function is executed?
If it is, then maybe the PackageLogs exits very fast so you don't have time to see the difference.

Try adding QThread::msleep(5000); before or after the function call.See if you notice any difference.

Regards

bpetty
16th July 2007, 18:49
I did a sleep() for 15 seconds... with no luck. My application just hangs till it is done sleeping. The cursor never changes.

marcel
16th July 2007, 18:54
Yes, use QApplication::setOverrideCursor to set the busy cursor and QApplication::resoreOverrideCursor to restore the arrow cursor.

Both these functions are static.

Regards

Gopala Krishna
17th July 2007, 15:13
If anyone has any ideas, I am all ears. Thanks.

Just a lame idea which might work. Add this before calling bool bRet = UpgradeUtils::PackageLogs();
qApp->processEvents()