Results 1 to 8 of 8

Thread: Get data from table view after item was edited?

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Get data from table view after item was edited?

    Hi,

    I have this application which uses the same table model as in the example given by Qt for item views: AddressBook.

    I also insert data in the tables as in the example. I would like that each time I edit a field in the table (directly on the table) a message box to appear containing the data from that field after editing. But I cannot find any signal that can be emitted when an item is changed.

    Any ideas?

  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: Get data from table view after item was edited?

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get data from table view after item was edited?

    but i don't have a QAbstractItemModel. I have a QAbstractTableModel where I add the data with the setData(data) method.

  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: Get data from table view after item was edited?

    What is the base class of QAbstractTableModel?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get data from table view after item was edited?

    that is the base class. I have the class
    Qt Code:
    1. TableModel::TableModel(QObject *parent) : QAbstractTableModel(parent).
    To copy to clipboard, switch view to plain text mode 

    I have an instance of this class declared in another class, where I add data to the table.

    Qt Code:
    1. ...{
    2. tableModel= new TableModel(this);
    3. }
    4.  
    5. void TableViewList::onDataAdded(float data1, float data2, float data3)
    6. {
    7.  
    8. int row = tableModel->rowCount(QModelIndex());
    9. tableModel->insertRows(row, 1, QModelIndex());
    10.  
    11. QModelIndex index = tableModel->index(row, 0, QModelIndex());
    12. tableModel->setData(index, data1, Qt::EditRole);
    13.  
    14. index = tableModel->index(row, 1, QModelIndex());
    15. tableModel->setData(index, data2, Qt::EditRole);
    16.  
    17. index = tableModel->index(row, 2, QModelIndex());
    18. tableModel->setData(index, data3, Qt::EditRole);
    19.  
    20. setModel(tableModel);
    21. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    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: Get data from table view after item was edited?

    What is the base class of QAbstractTableModel?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get data from table view after item was edited?

    I wrote above how i implemented. QAbstractTableModel was used like that. no base class. just like in the example for qt with the addressbook for item views

  8. #8
    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: Get data from table view after item was edited?

    What is the base class of QAbstractTableModel? Did I ask you how you implemented anything? Is it so hard to answer my question? Do you understand my question? Do you know what a "base class" is? Do you understand the concept of inheritance in C++?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to detect when item is changed in the table view?
    By schmimona in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2011, 10:06
  2. Replies: 1
    Last Post: 8th June 2011, 15:13
  3. Replies: 1
    Last Post: 3rd April 2010, 16:47
  4. Fetching data from table view
    By utkuaydin in forum Newbie
    Replies: 6
    Last Post: 19th January 2010, 08:27
  5. Table view->model->set data
    By tulsi in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2009, 09:36

Tags for this Thread

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.