[Qt-interest] QList and QUrl problem
Thiago Macieira
thiago at kde.org
Fri Mar 26 08:36:39 CET 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100326/f3135ab1/attachment.bin
More information about the Qt-interest-old
mailing list