schmimona
schmimona

Reputation: 869

How to detect when item is changed in a table view?

I have this table view where I write some data in different columns. I am adding the data by writing it in text boxes and clicking the "add" button. And I am modifying it by selecting a row in the table view, copying the data into the text boxes, editing it and pressing the "save" button.

The data from the text boxes apart from being sent to the table view is also being used for other calculations in my application.

I would like to be able to modify the data directly on the table view and then send the changed data to do the calculations that I need in another class - in my case.

For now I can modify the data on the table view but how could I send the signal that the data has been modified in the view?

Any ideas?

Upvotes: 2

Views: 3048

Answers (1)

Mat
Mat

Reputation: 206699

The data modification is handled by the model in Qt's Model/View framework.

To do what you want, get a handle to your TableView's model (via it's model() member), and connect a slot to the model's dataChanged signal.

This signal is emitted whenever the data in an existing item changes.

(There's a different signal if you want to react on column or row header changes.)

Upvotes: 2

Related Questions