@Jackmill said in QListWidget with checkboxes - checking more than one row at a time:
@jeremy_k said in QListWidget with checkboxes - checking more than one row at a time:
A flag or list of indexes to be modified could accomplish the same goal while leaving view management intact.
How might I do this? I'm having trouble thinking of a way to call setData without causing an endless loop.
void onDataChanged(const QModelIndex topLeft, const QModelIndex bottomRight, const QList<int> &roles)
{
static bool updating = false;
if (roles.contains(ItemDataRole::CheckStateRole) && !updating) {
updating = true;
auto value = topLeft.data(ItemDataRole::CheckStateRole);
for (auto index : selectionModel.selectedIndexes())
model->setData(index, ItemDataRole::CheckStateRole, value);
updating = false;
}
}
The code could also disconnect this (and only this) slot from the signal prior to the loop, and reconnect it at the end.