You can construct your own data structure however you want using the facilities offered by C++ and Qt. How you do it depends on exactly what the requirement is and how you have to manipulate the data.
One possibility for the problem as posted is:
struct Entry {
name(n), children(c)
{ }
};
QList<Entry> mySingleLevelHeirarchy;
struct Entry {
Entry(const QString &n, const QStringList &c = QStringList()):
name(n), children(c)
{ }
QString name;
QStringList children;
};
QList<Entry> mySingleLevelHeirarchy;
To copy to clipboard, switch view to plain text mode
If the structure needs to be arbitrarily deep
struct Entry {
Entry
(const QString &n,
const QList<Entry>
&c
= QList<Entry>
()): name(n), children(c)
{ }
QList<Entry> children;
};
QList<Entry> myMultiLevelHeirarchy;
struct Entry {
Entry(const QString &n, const QList<Entry> &c = QList<Entry>()):
name(n), children(c)
{ }
QString name;
QList<Entry> children;
};
QList<Entry> myMultiLevelHeirarchy;
To copy to clipboard, switch view to plain text mode
You could even use QStandardItemModel if you really wanted to.
Bookmarks