Results 1 to 3 of 3

Thread: deleting row from QSqlTableM​odel - not working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Smile deleting row from QSqlTableM​odel - not working

    I am trying to delete a row from QSqlTableModel which is show in the QTableView but it's not working please help.


    Qt Code:
    1. MainWindow *mainwindow; QSqlTableModel *model; QTableView *view;
    2.  
    3.  
    4. model = new QSqlTableModel(this,mainwindow->db);
    5. model->setTable("Tbl_Drawing"); model->select();
    6. view = new QTableView;
    7. QHeaderView *m_vert_header= view->verticalHeader();
    8. connect(m_vert_header, SIGNAL(sectionClicked ( int ) ), this, SLOT(deleteRow ( int ) ));
    9. view->setModel(model);
    10. view->show();
    To copy to clipboard, switch view to plain text mode 

    The above way I am able to show the entries........now deleting a row like this
    Qt Code:
    1. view->model()->removeRow(index, view->currentIndex());
    To copy to clipboard, switch view to plain text mode 
    But it's not removing the entry from the table..The item is still shown.....Please help me whats going wrong in this Thanks Sujan

  2. #2
    Join Date
    Dec 2009
    Posts
    65
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Default Re: deleting row from QSqlTableM​odel - not working

    maybe you should call model->submit(), or model->submitAll();

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: deleting row from QSqlTableM​odel - not working

    oh great, another one who posts the same thing in multiple places at once.

    http://www.qtforum.org/article/37876...t-working.html
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 1
    Last Post: 13th February 2012, 09:19
  2. deleting QStringList
    By timmu in forum Qt Programming
    Replies: 5
    Last Post: 18th December 2009, 14:36
  3. QMdiSubWindows - Deleting
    By Kerubu in forum Newbie
    Replies: 1
    Last Post: 25th August 2009, 06:23
  4. Deleting controls
    By alisami in forum Newbie
    Replies: 1
    Last Post: 18th June 2008, 16:19
  5. Deleting QProcess
    By user_mail07 in forum Qt Programming
    Replies: 7
    Last Post: 29th January 2008, 19:55

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.