[Interest] Help, please !!!
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Mon Apr 23 19:42:01 CEST 2012
Be careful with
List->append( &someOtherList );
If someOtherList goes out of scope, you will be pointing to a deleted list.
Since QList uses implicit sharing, the cost of removing the inner pointer isn't that much.
QList< QList< int > >
Is much safer
Scott
-----Original Message-----
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Nikos Chantziaras
Sent: Monday, April 23, 2012 10:34 AM
To: interest at qt-project.org
Subject: Re: [Interest] Help, please !!!
On 23/04/12 20:17, Miguel Milán Isaac wrote:
> I need to use QList<QList<int> *> * list; but I do not know how to
> initialize it.
>
> I want to do something like this:
> if (! listRemoved-> at (pos) -> contains (id)) {
> //do something
> }
QList< QList<int>* >* list = new QList< QList<int>* >;
// Fill it with 10 elements.
for (int i = 0; i < 10; ++i) {
list->append(new QList<int>);
// Or:
// list->append(&someOtherList);
}
Now every list[i] (or list->at(i)) gives you a QList<int>*. For example:
if (!list->at(pos)->contains(id)) {
// Do something.
}
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list