QList
是一个指针数组,可以使用下标
append(), prepend(), insert()
QList
list<<"a"<<"b"<<"c";
qDebug()<::iterator i; //定义读写迭代器
for(i=list.begin(); i!=list.end(); ++i)
{
qDebug()<<(*i);
*i="x";
}
QLinkedList
是一个链表,所以不能使用下标,只能使用迭代器访问数据项
QVector
在相邻的内存中存储一组数值,在前部或中间插入数据是很慢的,需要移动后面的所有数据。
既可以用下标,也可以用迭代器访问。子类有QPolygon, QPolygonF和QStack.
QMap
QMap
map.insert("beijing", );
map.insert("shanghai", );
map.insert("guangzhou", );
QMap
for(i=map.constBegin(); i!=map.constEnd();++i)
{
qDebug()<
mi=map.find("beijing");
if(mi!=map.end())
{
mi.value()=;
}
QMap与QHash比较
QHash以任意顺序存储,QMap按key键顺序存储
单次操作QMap快,多次操作QHash快
QVariant
QVariant v();//定义一个变量并初始化为709
qDebug<
map["int"]=;
map["double"]=709.9;
map["string"]="hello";
map["color"]=QColor(,,);
qDebug()<<map["int"]<<map["int"].toInt();
手机扫一扫
移动阅读更方便
你可能感兴趣的文章