Results 1 to 4 of 4

Thread: QTreeView: Find nearest item to mouse pointer

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeView: Find nearest item to mouse pointer

    I'd like to find out the item under the mouse pointer without having to left click the item first. There doesn't appear to be a function for this or am I missing something?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTreeView: Find nearest item to mouse pointer

    Item of what? QGraphicsScene, QListView... You can use
    Qt Code:
    1. listWidget->itemAt(QCursor::pos());
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeView: Find nearest item to mouse pointer

    Item of a QTreeView, as specified in the subject

    I didn't think I could use itemAt as it only worked for Widget views such as ListWidget rather than model views such as QTreeView, QTableView, etc ?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTreeView: Find nearest item to mouse pointer

    Quote Originally Posted by fatjuicymole View Post
    Item of a QTreeView, as specified in the subject
    That's a good point, and shows that I am definitely to tired...

    I didn't think I could use itemAt as it only worked for Widget views such as ListWidget rather than model views such as QTreeView, QTableView, etc ?
    For views it is QAbstractItemView::indexAt().

  5. The following 2 users say thank you to Lykurg for this useful post:

    dgjadeja (15th January 2013), squidge (31st October 2009)

Similar Threads

  1. Qt and VC++ instalation problem
    By gui.br in forum Installation and Deployment
    Replies: 6
    Last Post: 21st July 2009, 07:13
  2. free mouse pointer
    By raflegan in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2008, 14:11
  3. problems installing Qt opensource with msvc2008 support
    By odin1985 in forum Installation and Deployment
    Replies: 6
    Last Post: 24th May 2008, 09:06

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.