728x90
반응형
QMap
QMap은 키와 값을 연계해 관리할때 편리하다.
값 추가
QMap <QString, int> map;
map["one"] = 1;
map["two"] = 2;
map.insert("three", 3);
값 검색
auto Val= map.find( "one" ) ;
if(Val != Val. end()) {
qDebug() << Val.key() << Val.value()
}
Iterator
QMap<QString, int>::iterator i;
for (i = map.begin(); i != map.end(); ++i)
qDebug() << i.key() << ": " << i.value() << Qt::endl;
}
삭제
QMap<QString, int>::iterator i = map.begin();
while (i != map.end()) {
if (i.key().startsWith('_'))
i = map.erase(i);
else
++i;
}
728x90
반응형
'프로그래밍 > QT' 카테고리의 다른 글
Qt 화면 최대화, 최소화(Maximized, Minimized) (0) | 2023.04.03 |
---|---|
Qt QSplitter (0) | 2023.04.03 |
QT QDateTime (0) | 2022.09.14 |