View Full Version : model/view editing question

11th September 2008, 16:50
I have a model/view framework I'm fiddling with, where I want to enable editing... but only when I right-click on an item and click on "rename" in a menu... whereas a double-click will actually activate the item rather than edit it.

At the moment, I have editing enabled via the flags() function (Qt::ItemIsEditable), and whenever I activate (double-click) my item it also enters an edit mode. Functionally, this works... it's just a bit clunky.

If I simply disabled editing from the flags() function, could I use the built-in functionality via my "rename" menu option rather than building custom edit functions?

11th September 2008, 17:20
You have to change the edit triggers in the view. The model is fine. You want to change the method of editing the data, not the possibility to edit data, so the right place to look is the view.

11th September 2008, 18:52
Yeah, I was looking in the wrong spot... got it. What I needed in this case was a view->setEditTriggers(QAbstractItemView::SelectedClicked );. Thanks.