Results 1 to 5 of 5

Thread: Change cursor inside QTableview

  1. #1
    Join Date
    Nov 2006
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Change cursor inside QTableview

    Hi All,

    I would like to change the mouse cursor when I move the mouse pointer inside my QTableView over a row.

    I've tried this:
    Qt Code:
    1. void QTableView::mouseMoveEvent( QMouseEvent *pEvent )
    2. {
    3. int iRow = this->rowAt( pEvent->y() );
    4. if( iRow == -1 )
    5. {
    6. this->setCursor( QCursor( Qt::ArrowCursor ));
    7. }
    8. else
    9. {
    10. this->setCursor( QCursor( Qt::PointingHandCursor ));
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    But this unfortunately this does not work. The mouse cursor is not changing. What do I wrong? Any ideas?

    Many thanks and best regards

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Change cursor inside QTableview

    Just a guess:
    maybe rowAt() uses local Widget coordinates, but the event is giving global.
    Try to map to widget coordinates and see if it helps.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2006
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change cursor inside QTableview

    Hi high_flyer,

    with pEvent->y() I'm mapping to the local widget coordinates (pEvent->globalY() is the one which mapps global). Also when I move over a row inside my QTableView I can see (with qDebug()-output) that this function call works fine. But the cursor is not changing.

    Any ohter ideas or suggestions?

    Best regards

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Change cursor inside QTableview

    Hmm...
    Try first with out specifying a row.
    See if at all you get the cursor to change over the widget.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change cursor inside QTableview

    a mouseMoveEvent is only generated, if you press a button. If you want to generate the event always, you have to enable mouse tracking for the widget

Similar Threads

  1. Replies: 0
    Last Post: 27th July 2010, 12:48
  2. How can to change the QGraphicsTextItem 's cursor width?
    By robertkun in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2009, 03:49
  3. Change value inside QTableView or QSqlQuery
    By jano_alex_es in forum Newbie
    Replies: 1
    Last Post: 15th May 2009, 10:49
  4. Is it possible to change the cursor on a QGraphicsView?
    By draftpunk in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2008, 18:43
  5. change cursor
    By nicky in forum Qt Programming
    Replies: 2
    Last Post: 31st January 2007, 11:07

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.