Qt-interest Archive, August 2006
context menus : how to set the event as accepted ?
Message 1 in thread
Hi all,
In a subclass of QTreeView, I reeimplemented QWidget::contextMenuEvent() to
set up a context menu.
In the doc of QContextMenuEvent, it is said that :
> Context menu events contain a special accept flag that indicates whether
> the receiver accepted the event. If the event handler does not accept the
> event then, if possible, whatever triggered the event will be handled as a
> regular input event.
Hence, in MyTreeView::contextMenuEvent(), I call
QContextMenuEvent::accept()
on the QContextMenuEvent.
However, the event is still processed by the view as if it had not been
accepted.
Especially, an editor is open for the QModelIndex if this index was selected
in the view (not that my view's edit trigger is set as
QAbstractItemView::SelectedClicked).
Does anyone knows why the right button mouse press is treated as a normal
event, while it should not ?
I have another small question.
In my subclass, when calling programmatically QTreeView::edit(QModelIndex)
on an editable index, the editor is not opened, and Qt writes the warnigng
message :
edit: editing failed
on the stderror, unless the QModelIndex was first selected.
I've followed up the Qt code, and I don't see what's appening.
My editTrigger is set to QAbstractItemView::SelectedClicked.
However, I thought that calling ::edit() should open the editor no matter
the view's edditTriger flag..
Am I wrong ?
Very best-
Nicolas
---------------------------
qt-interest is a HUGE help.
Thx much to those who have replied to one of my messages !
--
[ signature omitted ]