Results 1 to 7 of 7

Thread: QPersistentModelIndex and QDataWidgetMapper

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    39
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default QPersistentModelIndex and QDataWidgetMapper

    Hi

    I am using a QDataWidgetMapper with a QSqlRelationalTableModel (Manual edit strategy). When a row is inserted into the model, I want the datawidgetmapper to display that row after it is saved to the database. I understand that when a row is inserted into the model, the model indexes are invalid and so I have been looking at using a QPersistentModelIndex to hold the index of the new row. The problem that I am having is that the persistent index appears to be invalid after model.submitAll.

    sample code:
    Qt Code:
    1. row = self.detailMapper.currentIndex()
    2. persistentIndex = QPersistentModelIndex(self.model.index(row,0))
    3. self.detailMapper.submit()
    4. self.model.submitAll()
    5. self.detailMapper.setCurrentIndex(persistentIndex)
    To copy to clipboard, switch view to plain text mode 

    Is this the right approach and how do I use persistent model indices correctly. I have looked at the documentation and posts on this forum but am not able to solve my problem.

    Thanks in advance
    Last edited by jpn; 1st July 2008 at 08:40. Reason: missing [code] tags

Similar Threads

  1. QDataWidgetmapper
    By locus in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2012, 11:24
  2. QCheckBox on QDataWidgetMapper
    By Banjo in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2008, 03:09
  3. QDataWidgetMapper and QSqlRelationalTableModel problem
    By larry104 in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 15:46
  4. QDataWidgetMapper question
    By larry104 in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2007, 15:30
  5. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 10:50

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
  •  
Qt is a trademark of The Qt Company.