Results 1 to 4 of 4

Thread: Model/View -- Sql Insert

  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Model/View -- Sql Insert

    Where would the appropriate place be to invoke code for inserting an item into a table? In this case I'm dropping onto a view and want something to show up as a result.

    Right now I'm calling insert to act on the container in the model. Then I call setdata and finally I actually call a sql statement to insert into the table. Should the sql insert be called elsewhere? I'm a bit uncertain about what would be "natural" in this case.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Model/View -- Sql Insert

    Do you use one of the editable sql models (QSqlTableModel or its subclass)? If so, you should be able to do it directly through the model.

  3. #3
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Model/View -- Sql Insert

    Howdy Wysota. Yeah I could have done that, but I implemented my own listmodel that derives from the abstract list model class. I was just wondering where the best place to put my sql statement would be. Of course it works right now, but in terms of the model/view architecture I'm not sure where the "proper" place would be to place the insert.

    Just wondering

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Model/View -- Sql Insert

    IMO in submit(), setData() or insertRow().

Similar Threads

  1. [Qt4.1] How to insert an image inside a Form?
    By Gonzalez in forum Qt Tools
    Replies: 5
    Last Post: 23rd September 2008, 11:20
  2. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56
  3. SQL problem
    By nimmyj in forum Qt Programming
    Replies: 4
    Last Post: 25th December 2006, 18:43
  4. how to insert an ' in a database
    By jh in forum General Programming
    Replies: 3
    Last Post: 17th August 2006, 02:47
  5. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06

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.