QMap<int, QString> mapCity;
mapCity.insert(1,"one");
mapCity.insert(2,"two");
...
mapCity.insert(9,"nine");
...
//Now, I want delete 1,2,3.
QMap<int, QString>::Iterator it;
for( it = mapCity.begin(); it != mapCity.end(); ++it)
{
if( it.key() < 4 )
mapCity.remove( it ); //Is that OK??
}
QMap<int, QString> mapCity;
mapCity.insert(1,"one");
mapCity.insert(2,"two");
...
mapCity.insert(9,"nine");
...
//Now, I want delete 1,2,3.
QMap<int, QString>::Iterator it;
for( it = mapCity.begin(); it != mapCity.end(); ++it)
{
if( it.key() < 4 )
mapCity.remove( it ); //Is that OK??
}
To copy to clipboard, switch view to plain text mode
Bookmarks