Results 1 to 3 of 3

Thread: Select QListView Item on MouseOver

  1. #1
    Join Date
    Feb 2015
    Location
    Cologne/Germany
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Select QListView Item on MouseOver

    Hi,

    i have a QListView containing custom Widgets and want them to be editable without first clicking in them. Currently - e.g. to check a QCheckBox - you have to select the item first before you can edit it.

    So my thought is to select the item whenever the mouse enters the widget. For this i have 3 ideas but i stuck in either case.

    1) Reimplement mouseMoveEvent on the QListView
    - I get coordinates but how can i determine which item is underneath?

    2) use eventFilter on QListView
    - How to get the selected row here?

    3) use eventFilter on the Widget and signal it through the delegate
    - Here i'd need to be able to get at least the QModelIndex from the Item, right?

    I guess option 3 is the most promising but i appreciate any help to find the solution for this.

    Thanks,
    René

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Select QListView Item on MouseOver

    You can use indexAt ( const QPoint & p ) const to determine the QModelIndex at the mouse cursor

  3. The following user says thank you to StrikeByte for this useful post:

    renevolution (25th February 2015)

  4. #3
    Join Date
    Feb 2015
    Location
    Cologne/Germany
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Select QListView Item on MouseOver

    Yay ... that's it ... thanks man.

Similar Threads

  1. Replies: 1
    Last Post: 20th May 2014, 06:46
  2. Replies: 10
    Last Post: 22nd June 2013, 00:05
  3. Replies: 0
    Last Post: 10th August 2011, 06:46
  4. QListView - To select a disabled item
    By agarny in forum Qt Programming
    Replies: 3
    Last Post: 10th July 2011, 01:23
  5. QTreeWidget select item
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 26th October 2007, 14:26

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.