Violet Giraffe
Violet Giraffe

Reputation: 33607

How to check if any item is being edited in the QTreeView or not?

I've subclassed a QTreeView and have overriden keyPresseEvent() to do stuff when certain keys are pressed. Naturally, I don't want to do that while an item is being edited. How can I check if editing is in progress or not?

Upvotes: 2

Views: 1783

Answers (2)

Csaba Torda
Csaba Torda

Reputation: 96

you can check the view's internal state to see if it is in editing state

if (my_treeview->state() != QAbstractItemView::EditingState)
{
   /* do some stuff */
}

Upvotes: 4

Ashot
Ashot

Reputation: 10979

You can use these functions. If edit is called but closeEditor or editorDestroyed is not called yet, it is in editing mode.

bool QAbstractItemView::edit ( const QModelIndex & index, EditTrigger trigger, QEvent * event ) [virtual protected]    
void QAbstractItemView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint ) [virtual protected slot]
void QAbstractItemView::editorDestroyed ( QObject * editor )   [virtual protected slot]

Upvotes: 2

Related Questions