Results 1 to 3 of 3

Thread: QTableView, QSqlTableModel and ProxyModel not the same row

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTableView, QSqlTableModel and ProxyModel not the same row

    I'm using a QSqlTableModel to read and write data to a sqlite database. At this model I apply a costum SortFilterProxyModel, the result is diplayed in a QTableView. My problem is:
    I want to eliminate a line selected by the user on the database. Without the sorting the user select the line and then I delete it directly from the model with modelTable->removeRow(index.row ()).
    If now I enable setSortingEnabled(true) in the QTableView or I use the SortFilterProxyModel to isolate some characters, the order of the row change and it is not the same of the model. It doesn't allow me to delete a line from the model with removeRow because the row number of the Table is not the same row number of the Model.

    How do I have to do for resolving the problem? have I perhaps mistaken approach?

    Thanks in advance
    (excuse for my bad English)

  2. #2
    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: QTableView, QSqlTableModel and ProxyModel not the same row

    QAbstractProxyModel provides means for mapping indexes from and to the source model. See
    J-P Nurmi

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

    AlmAck (6th January 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView, QSqlTableModel and ProxyModel not the same row

    Thanks a lot! was exactly what I need.

Tags for this Thread

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.