Thank you for the tips. Got the checkboxes working. -- Mike Jackson On 5/4/22, 10:06 AM, "Interest on behalf of Tony Rietwyk" <interest-boun...@qt-project.org on behalf of t...@rightsoft.com.au> wrote:
On 4/05/2022 11:43 pm, Michael Jackson wrote: > ... > Now on to figure out how to display checkboxes next to each item. I've tried: > > Qt::ItemFlags ImportDataStructureModel::flags(const QModelIndex& index) const > { > if(!index.isValid()) > { > return {}; > } > return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | QAbstractItemModel::flags(index); > } > > Which does not seem to show anything. I'll probably have to create a custom delegate. > -- > Mike Jackson > Hi Mike, If you return flag ItemIsUserCheckable in your model, then you must also return a valid variant with Qt::CheckState for data(Qt::CheckStateRole) - it won't just assume Qt::Unchecked. Ditto with the item widgets - besides item->setFlags, you need to call item->setCheckState as well. Tony _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest