void QAbstractItemModel::layoutChanged () [signal]
This signal is emitted whenever the layout of items exposed by the model has changed;
for example, when the model has been sorted(重新排序了). When this signal is received by a view, it should update the layout of items to reflect this change.
例如:当用户勾选了第一列的CheckBox后,要设置model中,QList中存储的值,
然后,通知视图,进行刷新界面
//允许用户编辑item,必须重写setData()函数
bool TradeTableModel::setData ( const QModelIndex & index, const QVariant & value, int role)
{
//允许用户编辑的只有3列 第一列CheckBox, 包裹数, 保价金额
if(role == Qt::CheckStateRole && index.column() == ORDER_ID)
{
//用户勾选 每行第一列的CheckBox
ORDER_LIST_STRUCT& orderData = m_OrderList[row];
orderData.m_bChecked = !orderData.m_bChecked;//修改model中的值,
//该行checkBox 勾选状态
emit ModelCheckBoxStateChanged(orderData.m_bChecked ? Qt::Checked : Qt::Unchecked);
emit layoutChanged();
}