Results 1 to 11 of 11

Thread: Multiple clicks required to get into edit mode on QTreeView

  1. #1
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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?

    The flags returned by my model are:
    Qt Code:
    1. if (0 == index.column())
    2. {
    3. return flags | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
    4. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by jpn; 7th August 2008 at 14:16. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple clicks required to get into edit mode on QTreeView

    try to catch signal
    Qt Code:
    1. void QAbstractItemView::clicked ( const QModelIndex & index )
    To copy to clipboard, switch view to plain text mode 

    and then in slot to do
    Qt Code:
    1. void QAbstractItemView::openPersistentEditor ( const QModelIndex & index )
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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

  4. #4
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple clicks required to get into edit mode on QTreeView

    do you inherit QTreeView or just use it like a widget?

  6. #6
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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

  7. #7
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple clicks required to get into edit mode on QTreeView

    maybe this will help you. In .NET 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.

  8. #8
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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.

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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..
    J-P Nurmi

  10. #10
    Join Date
    Aug 2008
    Location
    Ann Arbor Michigan
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Multiple clicks required to get into edit mode on QTreeView

    Quote Originally Posted by jpn View Post
    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.

  11. #11
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.