[Qt-interest] Why do I get a "" key in my map?

Jason H scorp1us at yahoo.com
Tue Jun 8 17:52:12 CEST 2010


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
    }

    if (_VSNs.keys().count())
    {
        _currentSite= ui.cmbSiteNames->itemText(0);
        ui.cmbSiteNames->setCurrentIndex(0);
    }
}

Initial data:
VSNs= (("???????",""))
cmbSiteNames is a QComboBox. It should have one item of "????????" with value of "". 

Ending data:
VSNs= (("", ""), ("???????",""))

Thanks!



      




More information about the Qt-interest-old mailing list