Compatibility Members for QMap

The following members of class QMapare part of the Qt compatibility layer. We advise against using them in new code.

Public Functions

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)

Member Function Documentation

void QMap::erase(const Key & key)

Use remove(key) instead.

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() beforehand.

For example, if you have code like

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

you can rewrite it as

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

iterator QMap::remove(iterator it)

Use erase(it) instead.

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

Use remove() then insert().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.