Questions tagged [qmap]

QMap is a Qt container class that implements a map a.k.a. a skip-list-based dictionary.

This container looks like this:

QMap< Key, T >

It stores key-value pairs, and provides access to the value by the key and vice-versa. It also provides iterator-based access. A typical usage of the QMap is as follows:

//constructs a map with strings as keys and integers as values.
QMap< QString, int > myMap;
//this will set the value for the key "qwerty" if it doesn't exist, or override the current value if it does exist:
myMap["qwerty"] = 15;
//accessing elements is as easy as this:
int i = myMap["qwerty"];

The official QMap documentation can be found here for Qt 4.8 and here for Qt 5.

189 questions
2
votes
2 answers

Getting a part of a QMap as a QVector

I have some elements in a QMap a-element. Now I want to get a vector of some values of a. The easiest approach would be (for me): int length = x1-x0; QVector retVec; for(int i = x0; i < length; i++) { …
arc_lupus
  • 3,942
  • 5
  • 45
  • 81
2
votes
1 answer

plotting points with geom_point() and gmap()

I have 20 UTM locations included below. EDIT I have modified the included data to include the locations in Lat Long and added additional code below. I get the same result with either UTMs or Lat, Long. I have double checked the points in google…
B. Davis
  • 3,391
  • 5
  • 42
  • 78
2
votes
2 answers

How do you serialize a QMap?

I'm trying to learn how to serialize QMap objects in windowed applications, using this code: #include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include #include #include void write…
Al C
  • 5,175
  • 6
  • 44
  • 74
2
votes
1 answer

Sort actual QMap by key

I have QMap. I need to sort it by key using natural comparison. I do: std::map map = c.toStdMap(); std::sort(map.begin(), map.end(), strnatcmp1>); However, this does not even…
Uylenburgh
  • 1,277
  • 4
  • 20
  • 46
2
votes
1 answer

nested QMap in qt

I am trying to use this code in my QT app 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…
goutham
  • 848
  • 2
  • 13
  • 27
2
votes
1 answer

Is QMap generating memory leaks?

as a newbie valgrind user I can't figure out the reason why it outputs the following message 40 bytes in 1 blocks are definitely lost in loss the offending code lines are the following: void KukaDevice::_init() { …
ragingbit
  • 220
  • 1
  • 3
  • 9
2
votes
0 answers

timed delayed use of qmap() in R?

G'day, I am trying to learn how to use the ggmap package in R, but am getting stuck at the very beginning. All I am trying to do is use the qmap() function to download maps, but I am getting some very strange results. I have…
Adam
  • 1,147
  • 3
  • 15
  • 23
2
votes
1 answer

Calling Memberfunctions out of a QMap

I have a class TypeData and want to store objects of that type in a QMap then I want to get a specific object out of the map and call a memberfunction of this object. But when I try to do that i get the following error message: error C2662:…
samoncode
  • 466
  • 2
  • 7
  • 23
2
votes
3 answers

const char* wrong behavior in Qt

I have a problem with returning a const char* from two functions from a class, by some reason the first value is a replica of the second value or some values is wrong, but both values returned are from different pointers, in this case two QMap, the…
1
vote
0 answers

Error "passing 'const QString' as 'this' argument discards qualifiers]" in QMap::insert method

I am making XmlReader and still don't know well where to use const modifier. With this code: const QMap XmlElement::readDomAttributes( const QDomElement& domElement) const { QMap
1
vote
1 answer

Is it possible to use to use QMultiMap::ConstIterator in own template class?

I want to iterate over a QMultiMap using QMultiMap::const_iterator it;` but the compiler complains error: expected ‘;’ before ‘it’ resulting in a error: ‘it’ was not declared in this scope for every usage. I tried…
mbx
  • 6,292
  • 6
  • 58
  • 91
1
vote
1 answer

Qt QMap.insert() failing

I have a levelObjects object that's a QList of QVariants of QMaps: QList< QVariant > levelObjects; Later on, when I try to change the value of something in one of the QMaps, it doesn't seem to do anything: qDebug() << "Before - " <<…
numegil
  • 1,916
  • 7
  • 26
  • 38
1
vote
2 answers

Can't add items to QMap

I have a problem. I assume I'm doing something really dumb. I'm new to C++ and Qt. I have a class SavedVar. I'm trying to add a key/value to a private member Qmap. When I call SavedVar::addVar(), the program crashes. SavedVar::addvar() is receiving…
nrhorner
  • 328
  • 6
  • 16
1
vote
0 answers

how convert from coordinate to pixel to calculate a linear distance between to points

in my QT application I have a QML module with a map. I have also a point A and a point B; I know the position of this 2 points in terms of geo coordinates (latitude and longitude). Now, I simply want draw a line between this 2 points. For some…
Archimede
  • 699
  • 3
  • 15
  • 28
1
vote
1 answer

How I can define a QMap with struct as key

I try to define a QMap which it's key is a C++ structure. struct ProcInfo_S { quint8 tech = 0; quint8 direction = 0; quint8 category = 0; }; QMap G; G[{2,3,4}] = 2; But when I compile this code, I get the…
Abolfazl Diyanat
  • 397
  • 2
  • 13