Regarding the implementation of QList
Hi All,
I want to implement two QList with the following property:
1. QList A - List of a specific classes say C1.
2. QList B - List of pointer from the member of QList A of type C1 so that we can change members of QList A by calling QList B.
In the QList, i am not able to locate any function that return pointer of the QList member.
Any idea how can we implement it.
regards,
Rachit Gupta
Re: Regarding the implementation of QList
I dont think it is a good idea to handle adresses of objects inside a container, since inserting method and algorithm may invalidate them. Even if it would work with a list, it not a good reflex.
If you want to share data, you can use shared pointers.
For instance, using STL and boost :
Code:
//type definition
class C1{};
typedef boost::shared_ptr<C1> C1ShPtr;
//list declaration
std::list<C1ShPtr> A, B;
//creating and sharing a item in the 2 lists
C1ShPtr item(new C1);
A.push_back(item);
B.push_back(item);
I let you convert this code with Qt containers to make this post to come back in Qt-related scope