PDA

View Full Version : Get data from table view after item was edited?



schmimona
7th September 2011, 09:47
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?

wysota
7th September 2011, 19:14
QAbstractItemModel::dataChanged()

schmimona
8th September 2011, 09:37
but i don't have a QAbstractItemModel. I have a QAbstractTableModel where I add the data with the setData(data) method.

wysota
8th September 2011, 11:40
What is the base class of QAbstractTableModel?

schmimona
8th September 2011, 13:30
that is the base class. I have the class
TableModel::TableModel(QObject *parent) : QAbstractTableModel(parent).

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



...{
tableModel= new TableModel(this);
}

void TableViewList::onDataAdded(float data1, float data2, float data3)
{

int row = tableModel->rowCount(QModelIndex());
tableModel->insertRows(row, 1, QModelIndex());

QModelIndex index = tableModel->index(row, 0, QModelIndex());
tableModel->setData(index, data1, Qt::EditRole);

index = tableModel->index(row, 1, QModelIndex());
tableModel->setData(index, data2, Qt::EditRole);

index = tableModel->index(row, 2, QModelIndex());
tableModel->setData(index, data3, Qt::EditRole);

setModel(tableModel);
}

wysota
8th September 2011, 13:32
What is the base class of QAbstractTableModel?

schmimona
8th September 2011, 13:39
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

wysota
8th September 2011, 13:47
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++?