Results 1 to 20 of 57

Thread: Record update windowd entered data saving

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Iasi, Romania
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Record update windowd entered data saving

    I have done some more "research" and this is what I have:
    rec.field("city").type() returns QVariant::Invalid - that's because rec does not contain a field named "city".
    rec.field("city_name").type() returns QVariant::String which is correct as long the database field city_name is a VARCHAR.

    Using rec.setValue("city", "London") apparently works because QSqlRecord::setValue(const QString & name, const QVariant & val) does nothing if the field ("city" in this case) does not exist. So the record is inserted in the database using the default value (0) for the field "city_name" which is contained by the record rec. In this case why rec.setValue("city_name", "London") doesn't work and model->insertRecord(-1, rec) returns FALSE?
    I have also found something that looks strange, at least for me. I run in MySQL QueryBrowser the query upon which the QSqlRelationalTableModel model is filled with data and a saw that I can't insert or update records in the resultset returned.

    I think I have to dig deeper into this model/view architecture. For now I will try a different approach and use a QSqlQuery("INSERT INTO ...") to make things going on, but the topic still remains opened.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Record update windowd entered data saving

    You might want to ask Trolltech about it, it might be some kind of bug or lack of documentation.

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Record update windowd entered data saving

    I know why submitAll is not working for me. I've set up foreign keys, but I had not done the JOIN statement, I'll try it now and report the result.
    Qt 5.3 Opensource & Creator 3.1.2

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.