문제

I am using QMap and I have pointers to the object as keys of the map. Using std::map I would write a comparator for pointers and declare my map as follow

std::map<Key*, Value, ComparatorOfPointers<Key> >

How I have to do with QMap? I cannot find in Qt documentation which template parameters are acceptable.

도움이 되었습니까?

해결책

QMap (unlike std::map) always uses operator< to compare the keys. So you will have to wrap the pointer in a class and define a suitable operator< for that class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top