Results 1 to 2 of 2

Thread: QStandardItemModel doubt.

  1. #1
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default QStandardItemModel doubt.

    Hi freiends i am working on a small project in which i have to display some data in a table with some 4 columns.. I am retrieving the data in the sqlite db and updating the model view. But i wanted to even save the data which is modified while viewing.. i saw void QStandardItemModel::itemChanged ( QStandardItem * item ) but how can i capture the text that i have changed while i viewed it..
    Qt Code:
    1. QSqlQuery sqpre("select Ch_Name,TagId,Chpos from tpchn");
    2.  
    3. if(sqpre.exec())
    4. {
    5. if (sqpre.first())
    6. {
    7. do
    8. {
    9. tpch.push_back(sqpre.value(0).toString());
    10. tagid.push_back(sqpre.value(1).toString());
    11. } while(sqpre.next());
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    And this part of the code to display the data retrieved from the db to the ModelView..

    Qt Code:
    1. for(int i=0;i< tagid.count(); i++)
    2. {
    3. QStandardItem *item = new QStandardItem(tagid.at(i));
    4. model->setItem(i, 0, item);
    5. }
    6. for(int j=0;j< tpch.count(); j++)
    7. {
    8. QStandardItem *item2 = new QStandardItem(tpch.at(j));
    9. model->setItem(j, 1, item2);
    10. }
    To copy to clipboard, switch view to plain text mode 
    how can i capture the text which is changed here so that i can save it back to the db.. i wanted to update the changes in the text i make in the tableview.

    thank you
    Last edited by rex; 5th February 2011 at 09:22.

  2. #2
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QStandardItemModel doubt.

    If you want to provide an editable model based on QSqlQuery than maybe you should check QSqlTableModel
    the model is editable, and allows you to set the edit strategy and so on...

    seems to me that you are trying to achieve what this model offers
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

Similar Threads

  1. doubt
    By AnithaRagupathy in forum Qt Programming
    Replies: 1
    Last Post: 8th February 2008, 06:06
  2. doubt
    By deepa.selvaraj in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2007, 09:23
  3. Doubt ?
    By Cutey in forum Qt Tools
    Replies: 2
    Last Post: 3rd March 2007, 09:45
  4. QT 4.1 in OSX I have a doubt
    By askot in forum Installation and Deployment
    Replies: 9
    Last Post: 25th February 2006, 06:14

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.