View Full Version : QList problem
scarecr0w132
1st January 2014, 09:56
Hello,
I want to make a QList like this
makeSphere
center
radius
makeBox
width
length
height
How can I do this?
Thank you!:)
aamer4yu
1st January 2014, 11:07
Use QTreeWidget / QTreeView
scarecr0w132
1st January 2014, 22:33
Hi,
I am processing a large amount of data.
Is QTreeWidget / QTreeView the best solution for this?
Thanks
Infinity
1st January 2014, 22:43
What do you mean with "make a QList like this"?
Do you want to display data like this? Then use a QTreeView.
What is the data source (a QList has no parents/childs)?
scarecr0w132
1st January 2014, 22:47
Hi Infinity,
I don't want to display.
I want to store data in something like a QList that has a parent(QString) and children(QString)
Thanks
ChrisW67
2nd January 2014, 00:16
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 {
Entry(const QString &n, const QStringList &c = QStringList()):
name(n), children(c)
{ }
QString name;
QStringList children;
};
QList<Entry> mySingleLevelHeirarchy;
If the structure needs to be arbitrarily deep
struct Entry {
Entry(const QString &n, const QList<Entry> &c = QList<Entry>()):
name(n), children(c)
{ }
QString name;
QList<Entry> children;
};
QList<Entry> myMultiLevelHeirarchy;
You could even use QStandardItemModel if you really wanted to.
scarecr0w132
2nd January 2014, 02:24
Thank you, problem solved
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.