Results 1 to 4 of 4

Thread: QtSqlQueryModel removeRow's problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Question QtSqlQueryModel removeRow's problem

    hi guys,I had to ask for help.thanks advance!
    my problem is the removeRow method in mycode never succeed:

    Qt Code:
    1. model->setQuery("select * from person");
    2. QTableView *view = new QTableView;
    3. view->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    ok,I can get 7 rows from the person table.
    now I try
    Qt Code:
    1. model->removeRow(0);
    2. model->removeRow(1);
    3. ...
    To copy to clipboard, switch view to plain text mode 
    however,It donse't work。everything in the view still stay.

    but if I use the flowing code:
    Qt Code:
    1. plainModel.setTable("person");
    2. plainModel.select();
    3. QTableView *view = new QTableView;
    4. view->setModel(&plaiModel);
    5.  
    6. plainModel.removeRow(0);
    To copy to clipboard, switch view to plain text mode 

    Ok,It works. there is 6 rows left in the view.

    so ,whats my problem in my first case? how can i resolve it?
    need i change any thing from QSqlQueryModel to QSqlRelationTableModel?
    but I would like to use setQuery method than setTable method.

    so ,give a help ,please.

    thx
    Last edited by jpn; 25th February 2008 at 19:46. Reason: missing [code] tags

Similar Threads

  1. Replies: 16
    Last Post: 7th March 2006, 15:57

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.