tags:

views:

160

answers:

2

I am trying to use this code in my QT app

QMap<QString,QMap>

but there is a build problem it says

C:/****/****/****/***/domparser.h:14: error: type/value mismatch at argument 2 in template parameter list for 'template<class Key, class T> class QMap'
+3  A: 

QMap is a template class, so you need to specify the type of the inner QMap like this :

QMap<String, QMap<QString, int> > myMap;

Note the space between the '>'s otherwise the C++ lexer thinks its the >> operator.

If you intended to try to store any kind of QMap as the value type, within your outer map, don't do it - you can't!

rep_movsd
"If you intended to try to store any kind of QMap as the value type ... you can't" - this could be read as meaning "no instantiation of QMap can be used as the value type of an outer QMap". I'm sure that's not what you meant, but for the avoidance of doubt: while "QMap<QString,QMap>" is not valid, it is possible to use a *given instantiation* of QMap as a value type, e.g. "QMap<QString, QMap<int,int> >".
Gareth Stockwell
... and, if the outer QMap is defined within a template, the parameters of that template could be used to instantiate the inner (value) QMap. For example, if the outer QMap is a member of `Foo<X,Y>` then its complete type could be `QMap<QString, QMap<typename X, typename Y> >`
Gareth Stockwell
Yes, my bad...I should have said that it needed a complete instantiable(resolvable?) types as the template type parameters
rep_movsd
A: 

sry but i don't get it.. how can i fill the inner QMap if it is not initiated?

Alex