[Qt-interest] QList and QUrl problem
ice stone
icestone6124 at yahoo.com
Fri Mar 26 14:55:53 CET 2010
Thanks. As you and another member mentioned, this is probably a detach() issue. I'm using QT 4.6.
Yan
--- On Fri, 3/26/10, Thiago Macieira <thiago at kde.org> wrote:
From: Thiago Macieira <thiago at kde.org>
Subject: Re: [Qt-interest] QList and QUrl problem
To: qt-interest at trolltech.com
Date: Friday, March 26, 2010, 3:36 AM
Em Sexta-feira 26. Março 2010, às 03.51.24, ice stone escreveu:
> I am trying to figure out a problem involving QList<QUrl>. Here is my code:
>
> QList<QUrl> test;
> QUrl url;
> url.setUrl("1");
> test.append(url);
> qDebug()<<test[0];
> url.setUrl("2");
> test.append(url);
> qDebug()<<test[0];
> url.setUrl("3");
> test.append(url);
> qDebug()<<test[0] << test[1] << test[2];
>
>
> And the output is:
> QUrl( "1" )
> QUrl( "2" )
> QUrl( "3" ) QUrl( "3" ) QUrl( "3" )
>
> My understanding of QList is that it allocates a memory in heap for every
> inserted item and delete them when they are removed from the list. But the
> output here seems to point to a single QUrl object for all three items.
> Anyone can help me to solve this puzzle? Thanks a lot.
It looks wrong... probably a missing detach in QUrl::setUrl.
Which version of Qt is that?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-----Inline Attachment Follows-----
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100326/91ff2351/attachment.html
More information about the Qt-interest-old
mailing list