I just found a post in qtcentre suggested Chapter 4 of Advanced Qt Programming and lo and behold, there's a discussion of a tree subsclassing QstandardItemModel and QStandardItem where each row of the tree is made up of three QstandardItem objects handling different properties of a single object.
The implementation source code is freely available
Basically, one has:
public:
}
QstandardItem *m_description; // display m_description
private:
Foo &m_foo;
};
class myItem : public QStandardItem {
public:
myItem(Foo &afoo) : QStandardItem(afoo.getName()), m_foo(afoo) {
m_description = new QStandardItem(afoo.getDescription());
}
QstandardItem *m_description; // display m_description
private:
Foo &m_foo;
};
To copy to clipboard, switch view to plain text mode
and then we insert a row of two QstandardItem in our model tree
StandardItem
*myModel
::appendRow(QStandardItem *parent, Foo
&afoo
) {
auto *doublet = new myItem(afoo);
parent->appendRow(QList<QStandardItem*>() << doublet
<< double->m_description);
return nameItem;
}
}
class myModel: public QStandardItemModel {
StandardItem *myModel::appendRow(QStandardItem *parent, Foo &afoo)
{
auto *doublet = new myItem(afoo);
parent->appendRow(QList<QStandardItem*>() << doublet
<< double->m_description);
return nameItem;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks