Thanks. I currently have the following code
producing the attached image. Remaining things are:Qt Code:
model->appendRow(parentItem); author1->setCheckable(true); parentItem->appendRow(author1); for (int i = 0; i < 3; ++i) { QStandardItem *item = new QStandardItem(QIcon("C:\\dataset_small.png"), QString("Book # %0").arg(i+1)); item->setCheckable(true); author1->insertRow(i, item); } ui.treeView->setModel(model);QStandardItemModel *model = new QStandardItemModel(); QStandardItem *parentItem = new QStandardItem(QIcon("C:\\dataset_small.png"), "Authors"); model->appendRow(parentItem); QStandardItem *author1 = new QStandardItem(QIcon("C:\\dataset_small.png"), "Smith, V"); author1->setCheckable(true); parentItem->appendRow(author1); parentItem->appendRow(new QStandardItem(QIcon("C:\\dataset_small.png"), "Campbell, C")); for (int i = 0; i < 3; ++i) { QStandardItem *item = new QStandardItem(QIcon("C:\\dataset_small.png"), QString("Book # %0").arg(i+1)); item->setCheckable(true); author1->insertRow(i, item); } ui.treeView->setModel(model);To copy to clipboard, switch view to plain text mode
1) I like the checkbox for the author node, but I'd like to have the radio button for the book items to force only one book can be selected at the time. Could you please elaborate on the QItemDelegate?
2) I also want to have a count of children next to the labels meaning I want to have a "2" next to the "Authors" string (since there are 2 authors) and a "3" next to "Smith, V" because he has 3 books
hey ...What About TreeView Qml Type
Bookmarks