Results 1 to 4 of 4

Thread: setDragMode() changes mouse pointer forever

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    101
    Thanked 15 Times in 15 Posts

    Default setDragMode() changes mouse pointer forever

    Hi!

    In my QGraphicsView I call setDragMode(QGraphicsView::ScrollHandDrag) in the constructor because my default mouse behavior is to drag scroll the view.
    This changes the cursor to the open hand cursor for good, and subsequent calls to setCursor(Qt::ArrowCursor) have no effect. How can I keep the default drag scroll feature and yet set a custom mouse pointer?

    CRuz

  2. #2
    Join Date
    Aug 2009
    Posts
    29
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: setDragMode() changes mouse pointer forever

    I also need this operation ,someone help

    found a solution: https://blog.csdn.net/weixin_4058308...ails/127418389

  3. #3
    Join Date
    Sep 2025
    Posts
    3
    Qt products
    Platforms
    Symbian S60

    Default Re: setDragMode() changes mouse pointer forever

    Quote Originally Posted by lanmanck View Post
    I also need this operation ,someone help

    found a solution: https://blog.csdn.net/weixin_4058308...ails/127418389
    You can try overriding viewportEvent in your Qt QGraphicsView and call setCursor() there after the drag mode sets its own cursor. That way your custom cursor will be reapplied each time.

  4. #4
    Join Date
    Sep 2025
    Posts
    3
    Qt products
    Platforms
    Symbian S60

    Default Re: setDragMode() changes mouse pointer forever

    Quote Originally Posted by Cruz View Post
    Hi!

    In my QGraphicsView I call setDragMode(QGraphicsView::ScrollHandDrag) in the constructor because my default mouse behavior is to drag scroll the view.
    This changes the cursor to the open hand cursor for good, and subsequent calls to setCursor(Qt::ArrowCursor slope game ) have no effect. How can I keep the default drag scroll feature and yet set a custom mouse pointer?

    CRuz
    ScrollHandDrag controls the cursor, so setCursor on the view is ignored. Set the cursor on the viewport or subclass the view and force it in events, for example viewport()->setCursor(myOpenHand); then switch in mousePressEvent and mouseReleaseEvent to your closed and open hand cursors while keeping ScrollHandDrag.

Similar Threads

  1. Replies: 3
    Last Post: 12th August 2016, 21:00
  2. Replies: 3
    Last Post: 22nd February 2013, 19:56
  3. Flickering mouse pointer
    By guiQt in forum Qt Programming
    Replies: 19
    Last Post: 13th September 2010, 18:20
  4. changing mouse pointer
    By bhogasena in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2009, 15:57
  5. How can I hide the mouse pointer?
    By dimaz in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2008, 19:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.