Results 1 to 3 of 3

Thread: QTreeView - how to force an end to a user edit

  1. #1
    Join Date
    Nov 2008
    Posts
    33
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeView - how to force an end to a user edit

    QT4 - X11

    I have a QTreeView set up to enable user editing of items. Very simple - double click an item's text and type the changes, <return> ends the edit and commits the change to the model - works a treat.

    If an edit is in progress and the user saves the file without hitting return first (and thus not exiting the editor), the changes are not written to disk ( they're not lost - they're still visible in the editor).

    I had thought that when the editor lost focus as the user hit the save button, it would end the editing session automatically, but no.

    Any suggestions as to how to force the editor to close and commit changes before saving the file please?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView - how to force an end to a user edit

    Under unix the keyboard focus and mouse focus are separate. If you want to force the editor to close, use the item delegate that handles it - there are closeEditor() and commitData() methods there.

  3. The following user says thank you to wysota for this useful post:

    onamatic (17th November 2008)

  4. #3
    Join Date
    Nov 2008
    Posts
    33
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView - how to force an end to a user edit

    Thanks for that info. wysota. You've fixed my problem instantly.

    I didn't realise mouse and keyboard focus were different things; Inow explicitly shift the focus to another widget before saving the file. That causes the editor to exit and commit data without me having to learn about item delegates. I'm all for an easy life!
    Last edited by onamatic; 17th November 2008 at 21:47. Reason: updated contents

Similar Threads

  1. Logging Qt User Actions
    By Frank J. Lhota in forum Qt Programming
    Replies: 14
    Last Post: 30th May 2014, 21:36
  2. Multiple clicks required to get into edit mode on QTreeView
    By JonInAnnArbor in forum Qt Programming
    Replies: 10
    Last Post: 26th November 2012, 18:59
  3. Edit items on QTreeView + QDirModel
    By junior0007 in forum Qt Programming
    Replies: 4
    Last Post: 23rd November 2007, 07:16
  4. nmake problems while building mysql driver
    By MarkoSan in forum Installation and Deployment
    Replies: 27
    Last Post: 25th May 2007, 12:57
  5. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01:48

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.