Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
4.5.2
-
None
-
WinXp SP3, VS 2005
Description
In a QTreeView an editor for an item and the treeview context menu can be invoked at the same time, when a left mouse click is followed
by a right mouse click quickly.
This shouldn't be possible, because a line edit has a context menu of its own.
Furthermore, during an action invoked from the tree context menu the editor will possibly be closed and the model's setData() method will be called.
This behaviour can lead to undesired results. In our case it spoiled the transaction logic of a CAD-Framework (two transactions overlapping, one triggered by context menu action, one by the closing editor)
To reproduce the effect please extend the QT simpletreemodel example by the following code
1) In treemodel.cpp add the ItemIsEditable flag:
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
{
...
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
}
2) In main() create an instance of this this class instead of QTreeView
class MyTreeView : public QTreeView
{
Q_OBJECT
public:
MyTreeView (QWidget * parent = 0 )
: QTreeView(parent)
protected:
virtual void contextMenuEvent( QContextMenuEvent * contextEv)
};
3) When you now left-click on an item, followed immediately by a right-click, first the item context menu will open, then the item edittor will occur.
(see attached screenshot)