extended selection in q3listview
Hi,
i want to use similar functionality as extended selection in Q3ListView( setSelectionMode(Q3ListView::Extended) ).
And remove the functionality of
-- multiple items can be selected by dragging the mouse over them.
from the extended selection as i have drag and drop feature in my App.
please provide any code snippet if possible.
regards
Re: extended selection in q3listview
Try overriding mouseMoveEvent() (or filtering the event) so that the Q3ListView implementation never receives any mouse move events..
Code:
{
// override mouseMoveEvent() to make sure Q3ListView::mouseMoveEvent() is not called
event->accept();
}
// OR
Something::Something()
{
listView->installEventFilter(this);
}
{
// returns true and therefore filters the event
// if the list view is receiving a mouse move event
return (event
->type
() == QEvent::MouseMove);
}
Re: extended selection in q3listview
hi,
I already reimplemented contentsMouseMoveEvent in my appl.
I think you misunderstood my problem. I have drag and drop in my app. for left mouse press and move , so if extended selection is used, it will select the items and the drag and drop is not working.
So is there any way to switchoff the behaviour of selection the items on mouse move for extended selection
regards
Re: extended selection in q3listview
This works just fine for me:
Code:
#include <QtGui>
#include <Qt3Support>
class MyListView : public Q3ListView
{
public:
MyListView
(QWidget* parent
= 0) : Q3ListView
(parent
) {
setSelectionMode(Q3ListView::Extended);
// just some dummy items
addColumn("");
for (int i = 0; i < 5; ++i)
new Q3ListViewItem
(this,
QString::number(i
));
}
protected:
{
Q_UNUSED(event);
}
};
int main(int argc, char* argv[])
{
MyListView list;
list.show();
return a.exec();
}
Re: extended selection in q3listview
Thanks a lot for the code.
If I use Q_UNUSED(event) in my app., it has no effect, and the mouse move on pressing the left mouse still selects the items below the mouse
I have reimplemented the drag operation in contentsMouseMoveEvent, so i cannot neglect this event.
So is there a way such that my drag along with no selection on mouse left button press and move works
regards,
sreedhar
Re: extended selection in q3listview
Are you passing the event to the base class implementation? Could you show us the relevant parts of the code?
Re: extended selection in q3listview
Yes i am passing the event to the base class implementation of q3listview
void QWaveTextView::contentsMouseMoveEvent ( QMouseEvent * me)
{
Q3ListView::contentsMouseMoveEvent(me);
if (!(me->buttons() & Qt::LeftButton))
return;
if ((me->pos() - mDragStartPos).manhattanLength()
< QApplication::startDragDistance())
return;
...
}
If i do not pass the event to the base class(q3listview), i do not get the drag to work.
I have also connected SIGNAL onItem(Q3ListViewItem *) of Q3ListView to some other slot for some other purpose, and if do not use the base class implementation, the slot connected to this signal also does not work.
regards,
sree
Re: extended selection in q3listview
You don't reimplement contentsMouseMoveEvent() for that. The default implementation already calls startDrag() when appropriate. What you need to reimplement is Q3ListView::dragObject(). And remember to mark items as draggable by Q3ListViewItem::setDragEnabled().