bool ConfigModel::setData(const QModelIndex &index, const QVariant &value, int role){ if (!index.isValid()) return false; if (role == Qt::CheckStateRole) { int row = index.row(); if (value == Qt::Checked) { checkedRows.insert(row); } else { checkedRows.remove(row); emit dataChanged(index, index); } return true; } return false;}..............void ConfigModel::setSelectAllState(int state){ for (int i = 0; i < rowCount(); ++i) setData(index(i, 0), state, Qt::CheckStateRole);}
connect(setCheckBox, SIGNAL(stateChanged(int)), configModel, SLOT(setSelectAllState(int)));
if (value == Qt::Checked) { checkedRows.insert(row); // ??? где сигнал ??? } else { checkedRows.remove(row); emit dataChanged(index, index); }
QVariant ConfigModel::data(const QModelIndex &index, int role) const{ if (!index.isValid()) return QVariant(); if (index.row() < 0 || index.row() >= stringList.size()) return QVariant(); switch (role) { case Qt::DisplayRole: return stringList.at(index.row()); case Qt::CheckStateRole: if (checkedRows.contains(index.row())) return Qt::Checked; else return Qt::Unchecked; } return QVariant();}
bool ConfigModel::setData(const QModelIndex &index, const QVariant &value, int role){ if (!index.isValid()) return false; if (role == Qt::CheckStateRole) { int row = index.row(); if (value == Qt::Checked) { checkedRows.insert(row); } else { checkedRows.remove(row); } emit dataChanged(index, index); return true; } return false;}