Сделал такое для TreeView
C++ (Qt)
class AccessoriesTreeView : public QTreeView {
Q_OBJECT
public:
AccessoriesTreeView(QWidget *parent = 0);
private slots:
void setPressedIndex(const QModelIndex &index);
private:
QModelIndex pressedIndex;
virtual void mouseDoubleClickEvent(QMouseEvent *event);
};
C++ (Qt)
AccessoriesTreeView::AccessoriesTreeView(QWidget *parent) : QTreeView(parent)
{
setEditTriggers(QAbstractItemView::NoEditTriggers);
setAlternatingRowColors(true);
setRootIsDecorated(false);
setSortingEnabled(true);
setAllColumnsShowFocus(true);
setExpandsOnDoubleClick(false);
connect(this,SIGNAL(pressed(QModelIndex)),this,SLOT(setPressedIndex(QModelIndex)));
}
void AccessoriesTreeView::setPressedIndex(const QModelIndex &index)
{
pressedIndex = index;
}
void AccessoriesTreeView::mouseDoubleClickEvent(QMouseEvent *event)
{
QModelIndex index = indexAt(event->pos());
if (!index.isValid()||(pressedIndex != index)) {
QMouseEvent me(QEvent::MouseButtonPress,
event->pos(), event->button(),
event->buttons(), event->modifiers());
mousePressEvent(&me);
return;
}
QPersistentModelIndex persistent = index;
if(event->button() & Qt::LeftButton)
emit doubleClicked(persistent);
if ((event->button() & Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
&& !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
emit activated(persistent);
}
смотри реализацию mouseDoubleClickEvent() для вьюхи, и переопределяй его, добавив фильтр для левой кнопки мыши