Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Regarding displaying busy cursor

    General and Desktop
    3
    3
    4872
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      Indrajeet last edited by

      Hi All

      I was performing some task in for loop so i want to display the cursor in busy mode untill that for loop is executed completly.
      I tried something like this

      @for(int i=0;i<size;i++)
      {
      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
      .
      .
      .
      .
      }
      QApplication::restoreOverrideCursor();
      @

      But in above case the cursor remains in busy state even after the loop is completed.

      How to reslove this?
      How to implement this?

      1 Reply Last reply Reply Quote 0
      • T
        tobias.hunger last edited by

        The cursor is pushed onto a stack, so you need to call restoreOverrideCursor as often as you did a setOverrideCursor. Check the documentation of those methods, it explains it.

        Move the setOverrideCursor outside of the loop.

        1 Reply Last reply Reply Quote 0
        • S
          szuzsq last edited by

          In my opinion, setOverrideCursor is corresponding to restoreOverrideCursor,
          so you can either

          @
          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
          for(int i=0;i<size;i++) {
          .
          .
          .
          }
          QApplication::restoreOverrideCursor();
          @


          or
          @
          for(int i=0;i<size;i++) {
          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
          .
          .
          .
          QApplication::restoreOverrideCursor();
          }
          @

          1 Reply Last reply Reply Quote 0
          • First post
            Last post