PDA

View Full Version : closeEditor on a QTreeWidgetItem



merlvingian
8th October 2006, 18:20
After reading through the docs I found

closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )

but it appears I would need a custom model in order to implement this call to close the editor on the tree item in edit mode.
My problem is when I add a new item to a subclassed QTreeWidget I call

QTreeWidget::editItem(newItem);
to allow an edit of the item that was just inserted.

Now if I use a context menu to add another item the mouse click will cause a close editor event and the next new item will be selected and put into edit mode and all is fine. The problem arises when you use a toolbar, or menu action to add the item it will not close the first item's edit mode and the newly added item will not produce the desired behavior.

My questions is there anyway to force a close editor event so the newly entered item will be able to call edit? Or is there another way to produce the desired results?

merlvingian
10th October 2006, 16:32
If anyone is interested you can force a closEditor event in this situation with a


setItemExpanded(oldItem,true);
Where oldItem is the previously created item left in edit mode.

Not very clean, but works for now none the less.