[Qt-interest] QList and QUrl problem
ice stone
icestone6124 at yahoo.com
Fri Mar 26 03:51:24 CET 2010
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.
Yan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100325/a14b1090/attachment.html
More information about the Qt-interest-old
mailing list