Results 1 to 4 of 4

Thread: QSqlTableModel Questions

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlTableModel Questions

    Hi,

    1. setFilter(cosnt QString &)

    How can I set more than one filter ? Ex: first_name = 'something' and last_name = 'another'

    2. insertRecord(int row,......) and setRecord(int row,.......)

    Is the row number related to the current query or the table?
    Where would the new row get added in the database?
    How should the primary key be generated for the new record?

    Thanks a lot
    Last edited by munna; 4th March 2006 at 07:03. Reason: More doubts

  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: QSqlTableModel Questions

    Quote Originally Posted by munna
    1. setFilter(cosnt QString &)

    How can I set more than one filter ? Ex: first_name = 'something' and last_name = 'another'
    Qt Code:
    1. setFilter("first_name = 'something' and last_name = 'another'");
    To copy to clipboard, switch view to plain text mode 

    2. insertRecord(int row,......) and setRecord(int row,.......)

    Is the row number related to the current query or the table?
    It is related to the model. row represents the index of the model.

    Where would the new row get added in the database?
    Depends on the row you enter and the way the underlying database works. For most uses -- "at the end".

    How should the primary key be generated for the new record?
    It should be autogenerated by the database or by your model's "insertRow()" (if you use a custom model).

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlTableModel Questions

    when i set a filter, my model changes. rite?

  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: QSqlTableModel Questions

    No. You have to call select() to update the model.

Similar Threads

  1. Replies: 4
    Last Post: 9th May 2008, 17:02
  2. QSqlTableModel verticak header connect
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 1st July 2007, 13:07
  3. Memory management questions (im new to Qt)
    By scarvenger in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 07:41
  4. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 12:25
  5. QSqlTableModel Help pls
    By munna in forum Newbie
    Replies: 1
    Last Post: 26th January 2006, 07:58

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.