PDA

View Full Version : QMap QList



dare5421
23rd March 2011, 23:05
hi everyone
I'm new to Qt

look at this code:


int node1;
QMap< int,QList<int> > map;
QList<int> adjacent = map.values(node1);



when i run it: boom
error: conversion from 'QList<QList<int> >' to non-scalar type 'QList<int>' requested

Zlatomir
23rd March 2011, 23:17
Look at the documentation: QMap::values() (http://doc.qt.nokia.com/latest/qmap.html#values) returns a QList of T's (in your case T is a QList<int>)

So you need to decide if you really need a QMap<int, QList<int> > then values(...) returns a QList<QList<int> > or use the value(...) (http://doc.qt.nokia.com/latest/qmap.html#value)member function to return a QList<int>