But setOverrideCursor()
has one disadvantage. As documentation said:
Sets the application override cursor to cursor.
Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.
This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.
Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the curently active application override cursor.
Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.
Link: http://qt-project.org/doc/qt-4.8/qapplication.html#setOverrideCursor
It means that all widgets will have this cursor and you can't change it. So I have next solution:
Set cursor to your mainwindow, it will be default cursor, but you be able to change cursor of every widget you want, but mainWindow's cursor will be default.
For example:
this->setCursor(QCursor(Qt::PointingHandCursor));//it is default cursor
//qApp->setOverrideCursor(QCursor(Qt::PointingHandCursor));
QPixmap pix("path");
QCursor cur(pix);
ui->textEdit->viewport()->setCursor(cur);//when we hover the textEdit we get this pixmap as cursor.