PDA

View Full Version : QListView and selecting item on click event



migel
25th May 2011, 13:33
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.html#installEventFilter
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.

Santosh Reddy
25th May 2011, 16:06
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.

migel
25th May 2011, 16:40
How to get to the item from the widget perspective, widget has not idea where it lives

Santosh Reddy
25th May 2011, 18:03
in your custom widget you need ignore the mouse click so that it is forwaded to the cusom widget's parent


void CustomWidget::mousePressEvent(QMouseEvent* e)
{
e->ignore();
}