Results 1 to 4 of 4

Thread: QListView and selecting item on click event

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QListView and selecting item on click event

    I have custom QListView with items. In each item I insert custom widget. The issue is that I can't select an item on click. Its working when I press it and drag it a bit (like few pixels on the screen), then the item is selected.

    If I remove widget from the items its working just fine.

    I have tried re implement this http://doc.trolltech.com/4.6/qobject...allEventFilter
    same issue, no click signal is emited !?!?!?!

    I was experimenting with all options focusing, selection on both QList and QWidgets.

    Had someone this issue before.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QListView and selecting item on click event

    to select an item, you need to click on the item area which in not occupied by the widget.

    If your custom widget occupies the complete item area, then you cannot select the item, you need to capture the mouse click event and pass it on to the item.

  3. #3
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListView and selecting item on click event

    How to get to the item from the widget perspective, widget has not idea where it lives

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QListView and selecting item on click event

    in your custom widget you need ignore the mouse click so that it is forwaded to the cusom widget's parent
    Qt Code:
    1. void CustomWidget::mousePressEvent(QMouseEvent* e)
    2. {
    3. e->ignore();
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Selecting an item from QListWidget
    By chandru@080 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2010, 06:30
  2. Replies: 0
    Last Post: 12th April 2010, 12:22
  3. selecting a specific QtreeList item
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2007, 13:45
  4. QListWidget and selecting an item
    By invictus in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 11:59
  5. Items in QListView should sort on Header Click
    By vinnu in forum Qt Programming
    Replies: 14
    Last Post: 10th November 2006, 12:49

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.