[Qt-interest] Why do I get a "" key in my map?
Andreas Pakulat
apaku at gmx.de
Tue Jun 8 18:10:39 CEST 2010
On 08.06.10 08:52:12, Jason H wrote:
> void DlgEditVSN::setVSNs(QMap<QString, QString> VSNs)
> {
> _VSNs = VSNs;
> while(ui.cmbSiteNames->count())
> ui.cmbSiteNames->removeItem(0);
>
> foreach(const QString& site, _VSNs.keys())
> {
> ui.cmbSiteNames->addItem(site, _VSNs.value(site)); // THIS LINE MAKES A NULL KEY IN VSNs
There's a bit of context missing, in particular you didn't quite formulate
a clear question. But QMap::value is documented to insert a
default-constructed value if there is no one yet in the map for the given
key. So its expected that value inserts into _VSNs if site doesn't exist in
it yet.
Andreas
--
You'll be sorry...
More information about the Qt-interest-old
mailing list