0

I have a QTableView connected to a QAbstractTableModel.
The model is used with QtConcurrent::map to make threads for the application (copying files)

I subclassed QStyledItemDelegate to display a QStyleOptionProgressBar in one of the tableviews cells, and the idea was to update the progress bar via the model. It works, but from 0 to 100% in one go, not smooth.

QAbstractTableModel::setData() is called in my "copy loop", but it seems that QAbstractTableModel::dataChanged() is only emitted when the loops ends. No matter what I do.

This might be a wrong approach, but I have no clue how to access a given progress bar in the table view from a thread.

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
user635818
  • 99
  • 2
  • 9

1 Answers1

2

You need to implement setData() yourself in your table model class that is subclassing QAbstractTableModel. The base class implementation does nothing and returns false. You're responsible of emitting the dataChanged() signal if the data was successfully set.

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
  • I have done that already. The problem seems to be because setData() is called inside a loop. When the loop ends, the model is updated. I just need it to happen inside the loop. – user635818 Jan 09 '13 at 21:46
  • You should look here (if it's still relevant), http://stackoverflow.com/questions/14230265/what-is-the-proper-way-to-set-qprogressbar-to-update-from-the-logic-layer – GoldenAxe Mar 15 '13 at 10:46