Results 1 to 3 of 3

Thread: How to remove a record from a table with a composed primary key using QModelIndex ?

  1. #1
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How to remove a record from a table with a composed primary key using QModelIndex ?

    Hello,

    How to remove a record from a table with a composed primary key using QModelIndex and removeRow?

    In tables with simple primary key (just one column) it works fine with:

    Qt Code:
    1. QModelIndex index = sequenceTableView->currentIndex();
    2. if (!index.isValid())
    3. return;
    4. sequenceModel->removeRow(index.row());
    5. }
    To copy to clipboard, switch view to plain text mode 

    but with 2 columns (with similar code) i can't delete the record and in the output window appears the message:

    QSqlQuery::value: not positioned on a valid record


    Any help would be appreciated.
    Thanks,
    Palma

  2. #2
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: How to remove a record from a table with a composed primary key using QModelIndex

    the problem is solved, the index was returning wrong types. I was pretending to remove a row from a QSqlRelationalTableModel whose index is formed by two fields that are foreign keys, and the index was returning the names instead of the ids....

  3. #3
    Join Date
    Jun 2012
    Posts
    33
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to remove a record from a table with a composed primary key using QModelIndex

    Can you please provide some input on how you solved this problem?

    Thanks,

    Pericles

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.