Multiple clicks required to get into edit mode on QTreeView
Hello:
I have a QTreeView (rootIsDecorated=false) with a QItemDelegate on the first column that uses a QLineEdit for editing. I have set editTriggers to QAbstractItemView::AllEditTriggers.
PROBLEM: In order to get into edit mode on that column I sometimes need to click up to 3 times.
Is there any technique to ensure that I get edit mode the very first time I click in the cell? :confused:
The flags returned by my model are:
Code:
if (0 == index.column())
{
return flags | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
It may even be ideal if that column was always in edit mode?
I set up a custom widget that uses vector if QLineEdits in a QVBoxLayout positioned next to a QTreeView for this effect, but then I must synchronize the vector of QLineEdits and the Model-View. Not exactly ideal...
Any help would be greatly appreciated.
best regards,
Jon K.
Ann Arbor Michigan U.S.A.
Re: Multiple clicks required to get into edit mode on QTreeView
try to catch signal
and then in slot to do
Re: Multiple clicks required to get into edit mode on QTreeView
Hello:
Thanx for the advise.
Unfortunately this does not seem to do the trick. I tried this and variations on it, including the mouse events, to no avail. :(
Any other thoughts?
best regards,
Jon K
Ann Arbor Michigan
Re: Multiple clicks required to get into edit mode on QTreeView
Oh, by the way...
I am using Qt 4.4 on Mac OS X and MS-Windows.
best regards,
Jon K
Ann Arbor Michigan U.S.A.
Re: Multiple clicks required to get into edit mode on QTreeView
do you inherit QTreeView or just use it like a widget?
Re: Multiple clicks required to get into edit mode on QTreeView
Hello:
I have a view class derived from QTreeView, primarily to make it be a fixed number of rows. In my derived class is where I hooked up the signal/slot connections, and tried to catch the mouse events.
best regards,
Jon K
Re: Multiple clicks required to get into edit mode on QTreeView
maybe this will help you. In .NET :rolleyes: ther is control property called EditMode, and when you put it on EditOnEnter your problem is solved. EditTriggers should be simmilar..
editTriggers : EditTriggers
This property holds which actions will initiate item editing.
This property is a selection of flags defined by EditTrigger, combined using the OR operator. The view will only initiate the editing of an item if the action performed is set in this property.
Access functions:
EditTriggers editTriggers () const
void setEditTriggers ( EditTriggers triggers )
enum QAbstractItemView::EditTrigger
flags QAbstractItemView::EditTriggers
This enum describes actions which will initiate item editing.
QAbstractItemView:: NoEditTriggers, 0, No editing possible.
QAbstractItemView:: CurrentChanged, 1, Editing start whenever current item changes.
QAbstractItemView:: DoubleClicked, 2, Editing starts when an item is double clicked.
QAbstractItemView:: SelectedClicked, 4, Editing starts when clicking on an already selected item.
QAbstractItemView:: EditKeyPressed, 8, Editing starts when the platform edit key has been pressed over an item.
QAbstractItemView:: AnyKeyPressed, 16, Editing starts when any key is pressed over an item.
QAbstractItemView:: AllEditTriggers, 31, Editing starts for all above actions.
Re: Multiple clicks required to get into edit mode on QTreeView
Hello:
Yes, edit triggers is precisely the means I supposed would address this interaction. I have set the edit triggers value to AllEditTriggers.
Should this not have done the trick?
Thanx for your thoughts.
Jon K
Ann Arbor Michigan U.S.A.
Re: Multiple clicks required to get into edit mode on QTreeView
Have you reimplemented any event handlers? Perhaps you forgot to call base class implementation..
Re: Multiple clicks required to get into edit mode on QTreeView
Quote:
Originally Posted by
jpn
Have you reimplemented any event handlers? Perhaps you forgot to call base class implementation..
Hello:
My derived class only re-implements sizeHint so I can make it a fixed height for a fixed number of rows.
Is that valid?
I briefly changed my code to use a QTreeView directly and it did not seem to have much of an impact...
best regards,
Jon K
Ann Arbor Michigan U.S.A.
Re: Multiple clicks required to get into edit mode on QTreeView
I had the same problem and was able to fix it by leaving the default edit triggers and connecting the view's clicked(QModelIndex) signal to its edit(QModelIndex) slot.