PDA

View Full Version : table view and model: layout signals and data changed signals



hml
21st October 2010, 20:11
Hello,

I have a QDialog with a QTableView and a QPushButton.
When the dialog shows up, the QTableView has 10 rows and 3 columns. It is a fixed table. However all the cells are empty except for the last column which contains a QPushButton for each row.

Under the QTableView, there is a Run... QPushButton. Connected to the click signal of it is my run() function.

run() calls a very long algorithm, the results of which are used to fill up the cells of the table that are still empty.

I understand at the end of run(), I need to notify my model (used by the view) of the newly available data.

My model inherits from QAbstractTableModel. It has overriden data(), rowcount(), columncount(), headerData().

Am I supposed to override setData() too? Is that for "editable" just from the GUI or editable models from anywhere?
I could just have a custom member function to update the private member containers of the model, and call it instead of calling setData() for each index individually.

Then I need to emit a signal after that. The number of row/columns doesn't change. The sorting order of cells doesn't change. The cells just change from empty to having some numerical value.

Do I emit dataChanged or layoutChanged? There's more than 1 layout... signal I think. Which one?

The next step will be to run the long algorithm in another thread so that the GUI remains responsive, then when done update the model.

Can the signal be emitted from another thread (boost::thread) or do I need to make sure I emit the signal from wherever thread the run() function of my button was executed in (I suppose this is the main thread which is the GUI thread)

regards,

hml
24th October 2010, 12:09
any advice would be appreciated?