美文网首页
QMap深度解析

QMap深度解析

作者: YBshone | 来源:发表于2018-01-17 11:53 被阅读0次

    话不多说,直接上代码
    QMap之列表List两种遍历

    载具列表

    void CUnitTmplMgr::removeUnitTmpl(int           utid)
    {
        if(m_unitTmplList.find(utid) != m_unitTmplList.end())
        {
            UnitTmplInfo info;
            info = m_unitTmplList[utid];
            m_unitTmplList.remove(utid);
            emit unitTmplRemoved (info);
        }
    }
    

    任务信息

    void    CTaskInfoDock::computTmplInfo(UnitTmplInfo & info)
    {
        UnitTmplList tmplList = m_unitTmplMgr->unitTmplList();
        QString str;
        str = QString("%1").arg(tmplList.size());
        m_tmplRootItem->setText(1,str);
    
        int fwPlane = 0;
        int vehicle = 0;
        int warShip = 0;
        int chopper = 0;
        int station = 0;
        int missile = 0;
    
        UnitTmplList::iterator it = tmplList.begin();
        for(;it != tmplList.end();it++)
        {
            switch(it->unitTmplType)
            {
            case UnitTmplInfo::UNITTMPL_FWPLANE:
                fwPlane++;
                break;
            case UnitTmplInfo::UNITTMPL_VEHICLE:
                vehicle++;
                break;
            case UnitTmplInfo::UNITTMPL_WARSHIP:
                warShip++;
                break;
            case UnitTmplInfo::UNITTMPL_CHOPPER:
                chopper++;
                break;
            case UnitTmplInfo::UNITTMPL_STATION:
                station++;
                break;
            case UnitTmplInfo::UNITTMPL_MISSILE:
                missile++;
                break;
            default:
                break;
            }
        }
        str = QString("%1").arg(fwPlane);
        m_tmplRootItem->child(0)->setText(1,str);
        str = QString("%1").arg(vehicle);
        m_tmplRootItem->child(1)->setText(1,str);
        str = QString("%1").arg(warShip);
        m_tmplRootItem->child(2)->setText(1,str);
        str = QString("%1").arg(chopper);
        m_tmplRootItem->child(3)->setText(1,str);
        str = QString("%1").arg(station);
        m_tmplRootItem->child(4)->setText(1,str);
        str = QString("%1").arg(missile);
        m_tmplRootItem->child(5)->setText(1,str);
    }
    

    相关文章

      网友评论

          本文标题:QMap深度解析

          本文链接:https://www.haomeiwen.com/subject/scnyoxtx.html