March 30, 2012

neeraj2012 neeraj2012
Lab Rat
8 posts

Check cursor State

 

i am setting cursor state by QApplication::setOverrideCursor( Qt::WaitCursor );
but i have to check whether the cursor is in normal form of not and then i have to call
QApplication::restoreOverrideCursor();
how can i check?

if ( ? )
QApplication::restoreOverrideCursor();

8 replies

March 30, 2012

Andre Andre
Robot Herder
6420 posts

QApplication takes care of that for you. It keeps an internal stack. All you need to do, is make sure that your number of setOverrideCursor calls matches the number of your restoreOverrideCursor calls.

from the docs:

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.

March 30, 2012

neeraj2012 neeraj2012
Lab Rat
8 posts

in our project .exe is setting cursor but our plugins after loading has to restore that so it is not possibe?

March 30, 2012

Andre Andre
Robot Herder
6420 posts

I don’t quite get the requirement.

March 30, 2012

neeraj2012 neeraj2012
Lab Rat
8 posts

We have project called OrderXpress
in our project we use two plugins photoXpress and AlbumXpress
we load these plugins through container and setting cursor to wait state but in plugins
it internally setting cursor for differnt modes so how can i identify the cursor state to restore it in plugins as our plugins did not have the knowledge of our container.

March 30, 2012

Andre Andre
Robot Herder
6420 posts

They don’t need that knowledge. If they set their own cursor override, they should re-set it as well. The same goes for the container: if it sets the override, it should reset it as well.

It’s a good candidate for a RAII class, by the way.

March 30, 2012

neeraj2012 neeraj2012
Lab Rat
8 posts

Thanks sir. By the way which country u belongs to?

March 30, 2012

Andre Andre
Robot Herder
6420 posts

neeraj2012 wrote:
Thanks sir. By the way which country u belongs to?

Check my profile by clicking on my name next to my picture :-)

March 30, 2012

neeraj2012 neeraj2012
Lab Rat
8 posts

Got it , its my pleasure to have you sir .Thanks for your precious time but i will be available with my Questions so please guide me.

 
  ‹‹ Ways to keep GraphicItems inside GraphicsSceneRect      QWidgetTab delete internal padding ››

You must log in to post a reply. Not a member yet? Register here!