Results 1 to 2 of 2

Thread: QSqlRelationalTableModel editing probllem

  1. #1
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default QSqlRelationalTableModel editing probllem

    This is a very strange situation. The code is small and simple
    Qt Code:
    1. model = new QSqlRelationalTableModel();
    2. model->setTable("InputLabels");
    3. // model->setRelation(model->fieldIndex("label_id"), QSqlRelation("Labels", "id", "text"));
    4. model->select();
    5. ui->tableView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    when i run it like this i can edit my data directly in the tableView and post it with model->submitAll()
    but if remove comment from setRelation line, every time i exit focus after editing data, the data in cell reverts to original value. column i edit is not the one with relation. So if i use setRelation i am unable to edit data in tableView. Am i missing something or it is "a bug".
    anyone with similar problem?

    I also wanted to make the relation column read only, but that is another story

  2. The following user says thank you to davidovv for this useful post:

    vds (17th April 2013)

  3. #2
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSqlRelationalTableModel editing probllem

    answering my own thread
    the problem was that the table had no primary key,
    i still think that QSqlRelationalTableModel should behave the same, and that this is some kind of BUG, or at least missing functionallity.
    With setRelation, QSqlRelationalTableModel has more information about database than without setRelation.

    thanks davidovv

  4. The following user says thank you to davidovv for this useful post:

    vds (17th April 2013)

Similar Threads

  1. when to use QSqlRelationalTableModel?
    By babygal in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2010, 10:19
  2. PostgreSQL + QSqlRelationalTableModel + editing problem
    By Mirko1974 in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2010, 09:36
  3. QSqlRelationalTableModel
    By marvin in forum Newbie
    Replies: 2
    Last Post: 19th November 2008, 22:29
  4. QSqlRelationalTableModel
    By jjay in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2008, 16:20
  5. Replies: 5
    Last Post: 24th May 2007, 12:11

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.