Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Blank QCursor is only temporary
Forum Updated to NodeBB v4.3 + New Features

Blank QCursor is only temporary

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    AnnaB
    wrote on last edited by
    #1

    I assume I am missing something small, but fundamental. I "hide" the Cursor in a certain mode in my application, which works until I move the mouse. Once I move the mouse, the cursor reappears. I'd like it to remain hidden until I explicitly set the cursor to an arrow.

    This is what I do in the QMainWindow:
    if(mouse)
    {
    _glScene->acceptTouchEvents(false);
    _skipMouseUpdate = true;
    grabMouse();
    qApp->setOverrideCursor( QCursor( Qt::BlankCursor ) );

    } else
    {
        _glScene->acceptTouchEvents(true);
        releaseMouse();
        qApp->setOverrideCursor( QCursor( Qt::ArrowCursor ) );
    }
    

    I am not accidentally calling qApp->setOverrideCursor( QCursor( Qt::ArrowCursor ) );. My QMainWindow contains many children, including a QGraphicsView, QGraphicsScene and QGraphicsObject.

    Thanks, AB

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Where is that code placed? In some event handler? Maybe one of the widgets you move the mouse over sets a cursor?

      In any case you should not call setOverrideCursor like that. Instead of setting ArrowCursor to reset the cursor you should call restoreOverrideCursor(). What you're doing is pushing new cursors on the stack and never popping them back.

      A 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        Where is that code placed? In some event handler? Maybe one of the widgets you move the mouse over sets a cursor?

        In any case you should not call setOverrideCursor like that. Instead of setting ArrowCursor to reset the cursor you should call restoreOverrideCursor(). What you're doing is pushing new cursors on the stack and never popping them back.

        A Offline
        A Offline
        AnnaB
        wrote on last edited by AnnaB
        #3

        @Chris-Kawa said:

        restoreOverrideCursor

        Thank you very much for the advice to reset the override cursor.

        The code is in a sort of event handler. It is possible that a widget overrides it, but I am not sure where to look for it as this is the only location in the entire project that references the QCursor class.

        edit: after a bit of investigation, the problem goes away if I comment out grabMouse(). Haven't found a good work around yet, but it's a start.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AnnaB
          wrote on last edited by
          #4

          Okay, so it looks like even grabMouse overrides the cursor, which is not what I understood from the documentation. Easy solution is to use the overloaded method:

              grabMouse(Qt::BlankCursor);
          
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved