Compatibility Members for QMap

以下成员源于类 QMap are part of the Qt compatibility layer. We advise against using them in new code.

公共函数

void erase (const Key & key )
iterator insert (const Key & key , const T & value , bool overwrite )
iterator remove (iterator it )
iterator replace (const Key & key , const T & value )

成员函数文档编制

void QMap:: erase (const Key & key )

Use remove( key ) 代替。

iterator QMap:: insert (const Key & key , const T & value , bool overwrite )

Use the two-argument insert () overload instead. If you don't want to overwrite, call contains () 事先。

例如,若有代码像

QMap<QString, int> map;
...
map.insert("delay", 30000, false);
					

可以把它重写成

QMap<QString, int> map;
...
if (!map.contains("delay"))
    map.insert("delay", 30000);
					

iterator QMap:: remove ( iterator it )

Use erase( it ) 代替。

iterator QMap:: replace (const Key & key , const T & value )

使用 remove () then insert ().