Results 1 to 2 of 2

Thread: QSqlRecord setValue doesn't set the value

  1. #1
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QSqlRecord setValue doesn't set the value

    I have a TableView and I create a QSqlQueryModel and then set the the table. All that works well and good.

    From another class, I look at a record of the model based on the index.
    If a certain value is null, then I give it a value like so:

    Qt Code:
    1. // int rowIndex is passed
    2. QString Image_Set_ID = "some value";
    3. QVariant qvImage_Set_ID;
    4. qvImage_Set_ID.setValue(Image_Set_ID);
    5. ((QSqlQueryModel*)(tableView->model()))->record(rowIndex).setValue("Image_Set_ID", qvImage_Set_ID);
    To copy to clipboard, switch view to plain text mode 

    But then if I look at the record from the model of the tableView again, it isn't updated.

    Thanks,
    Sean

    What is missing?
    Last edited by wysota; 7th February 2008 at 20:18. Reason: reformatted to look better

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QSqlRecord setValue doesn't set the value

    QSqlQueryModel is read only, that's one thing. Changing the record doesn't modify the database (record() returns a copy of the record), that's another thing.

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

    sgmurphy19 (8th February 2008)

Similar Threads

  1. SetValue
    By phillip_Qt in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2007, 22:45
  2. QSqlRecord becoming invalid
    By mikro in forum Newbie
    Replies: 5
    Last Post: 3rd October 2006, 18:00
  3. QSqlRecord problem
    By stevey in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 22:32

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.