Results 1 to 6 of 6

Thread: QTreeWidget - Edited Rows

  1. #1
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeWidget - Edited Rows

    Hi,

    I have a QTreeWidget with 1 editable column. If a user edits any value in any rows i want to keep track of those rows which were edited. Is there some way to do that.

    If possible please give some sample code.

    Thanks...

  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: QTreeWidget - Edited Rows

    What do you mean by "keep track"? Know which were edited or know history of values in each field?

  3. #3
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget - Edited Rows

    Hi,

    By keep track i mean know each rows which were edited as well as the values in the columns of each rows that were edited. Actually i have a file from which i parse the data and show it in QTreeWidget. Now a user cam edit the values and then can save. I need to copy the orginal file and change the values which user have updated in that file.

    Thanks.

  4. #4
    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: QTreeWidget - Edited Rows

    If you need the full history then I suggest having a role "previousvalues" in the model/item and store a list of previous values there. Then you can query for the data with this role and see if anything is there. But I'd strongely suggest using the model approach so that you can reimplement setData() and make sure nothing screws up your data. Then you can reimplement submit() and do the saving in there.

  5. #5
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget - Edited Rows

    Can you provide me with some example or sample code to that. That will be helpful.

    Thanks....

  6. #6
    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: QTreeWidget - Edited Rows

    I can't, sorry - it highly depends on the data backend. And if you ask about implementing an own model, search the forum and take a look at the wiki and Qt reference manual.

    Assuming you're not a newbie (if you're posting this question in Qt programming and not Newbie), you can probably handle reimplementing data() and setData() in for instance QStandardItemModel. And if you're a minimalist, you don't have to do even that. Just reimplement setData() for your custom tree widget item. Just make sure you always use proper methods when manipulating the object.

Similar Threads

  1. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32
  2. Replies: 1
    Last Post: 28th September 2006, 06:21

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.