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'
goutham
  • 848
  • 2
  • 13
  • 27

1 Answers1

6

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.

[edited]

If you intended to try to store a generic QMap as the value type, rather than a concrete instance of QMap, within your outer map, you can't!

You cannot have something like QMap, because QMap itself is not a type, its a template - it only names a type when the template parameters are specified

rep_movsd
  • 6,675
  • 4
  • 30
  • 34
  • "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" is not valid, it is possible to use a *given instantiation* of QMap as a value type, e.g. "QMap >". – Gareth Stockwell Mar 22 '10 at 08:00
  • ... 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` then its complete type could be `QMap >` – Gareth Stockwell Mar 22 '10 at 08:03
  • Yes, my bad... I should have said that it needed a complete instantiable(resolvable?) types as the template type parameters – rep_movsd Mar 22 '10 at 18:20