Значения QMap как структурыC++

Программы на C++. Форум разработчиков
Anonymous
Значения QMap как структуры

Сообщение Anonymous »

Предположим, у нас есть этот образец:

Код: Выделить всё

struct test
{
QString name;
int count = 0;
};

QMap map;
test test1;
test1.name = "doc1";
map.insertMulti("pen",test1);

test test2;
test2.name = "doc2";

map.insertMulti("pen",test2);

if(map.contains("pen"))
{
map.value("pen",test1).count++; // Here goes the error
//map["pen"].count++; //works but increments count of last inserted struct
}

foreach (test value, map) {
qDebug() 

Подробнее здесь: [url]https://stackoverflow.com/questions/53472279/qmap-values-as-structs[/url]

Вернуться в «C++»