qt之QMutiMap遍历

遍历方法思想,使用map遍历,已知遍历的key值对应value个数

QMutiMap生成代码示例

#include 
QMutimap m_job_total_status_mutimap;
QMutimap set_job_mutimap()
{
    m_job_total_status_mutimap.clear();				 
    m_job_total_status_mutimap.insert(QString::fromWCharArray(pJobStatus[ul].pJobID)
					,QString::number(pJobStatus[ul].ulJobStatus));
				 
    m_job_total_status_mutimap.insert(QString::fromWCharArray(pJobStatus[ul].pJobID)
					,QString::number(pJobStatus[ul].ulErrorCode));
				 
    m_job_total_status_mutimap.insert(QString::fromWCharArray(pJobStatus[ul].pJobID)
					,errorinformation);
				 
    m_job_total_status_mutimap.insert(QString::fromWCharArray(pJobStatus[ul].pJobID)
					,QString::number(pJobStatus[ul].ulRemainingEstimateTime));
    return m_job_total_status_mutimap;
}

1.QMutimap声明为全局变量的初始化有待进一步研究

2.正常生成QMutimap没有问题,但是在定时器等高频生成过程中,其生成有空值现象,处理有待研究 

    QMultiMap m_get_jobstatusmutimap = set_job_mutimap();
	QMultiMap::iterator ites; //遍历map  
	for ( ites = m_get_jobstatusmutimap.begin(); ites != m_get_jobstatusmutimap.end(); ++ites ) {
		for(int m = 0; m < jobid_list.size(); ++m)
		{
			if (ites.key() == jobid_list.at(m))
			{
				if (n%4 == 0)
				{
					waittotaltime += ites.value().toInt();
					
				}
				if (n%4 == 1)
				{

					if(ites.value() != "")
					{
						errorinformation = ites.value().toStdString();
					}
				}
				if (n%4 == 2)
				{
					if(ites.value() != "")
					{
						errorcode = ites.value().toStdString();
					}
				}
				if (n%4 == 3)
				{
					jobstatus = ites.value().toStdString();
                    jobid = ites.key().toStdString();

				}
			}
		}
		n++;
	}
}

 

你可能感兴趣的:(C++)