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
0
votes
1 answer

How to serialize a QHash and a QMap in a single file?

I have a QHash and a seperate QMap. I can serialize them alone. But I would like to serilize them in a single file: QMap myMap; QHash myHash; // .. fill: both have 4 (key,value) pairs. // write here QDataStream out…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
0
votes
2 answers

Compare two QMaps

What's the best way to compare two QMaps and remove the entries not in first map and add the entries of map two to the first one? Let's say I have a map with {1,2,3} and a map with {1,2,4} and I want to keep in first map {1,2,4}. Thanks.
adapto
  • 95
  • 1
  • 12
0
votes
0 answers

Iterating over Qmap with QSharedPointers as values

I have a QMap that includes QSharedPointers as values. Everytime I try to loop through the map and qDebug the results I'm getting memory handling erros. Values of the map are objects of Team class which inherits from QObject. QMap…
mmok
  • 1
  • 1
0
votes
1 answer

conflicting declaration of static QMap

I have a simple Customer class with 3 static QMap //customer.h class Customer : public QObject { Q_OBJECT public: static QMap const names; static QMap const keywords; static…
BlueMagma
  • 2,392
  • 1
  • 22
  • 46
0
votes
1 answer

How to use QSet as value in QMap?

I'm using Qt and I want to declare following container: QMap > map; Here ClassSharedPtr is the boost shared ptr of class "Class". typedef boost::shared_ptr ClassPtr; I'm getting following errors after…
BSalunke
  • 11,499
  • 8
  • 34
  • 68
0
votes
2 answers

How do I retrieve the value as my enum type from a QMap?

I have a QMap like this: QVariantMap dictionary; dictionary.insert("name", KeywordType::name); but when I try to retrieve the value of name key as enum KeywordType type, which is KeywordType::name it return none (that's zero in the KeywordType…
Jack
  • 16,276
  • 55
  • 159
  • 284
0
votes
2 answers

Inserting QObject * in QMap - cannot initialize or pass the pointer

I have two classes set up, InputFile and InputStream. Both inherit QObject, and are initialized with the Q_OBJECT macro. InputFile contains a QMap, creates InputStream objects and inserts them in the QMap. InputStream is…
Alexandre
  • 5
  • 6
0
votes
1 answer

Chart 3 variables in ggplot

I am struggling to combine colour coding to a Z variable (ShipSpeedGPS.Knots.) in a Y Variable (Lon) and X Var (Lat) plot. I have mapped the route via the following commands NWSMAP = qmap('brunei', zoom=3) NWSMAP + geom_point(aes(x=Lon, y=Lat),…
0
votes
2 answers

Accessing the value in Qmap with the help of its key

I have a QMap and I have defined it as QMapModelMap where ModelVariables is a structure with parameters valueref,value and ID. I want to access the parameter value defined in the structure. I wrote the following code but it…
0
votes
1 answer

what is the default value received for map of map when used value in Qt

I have a QMap > data; if I say data.value(key); -> what will be the return value if value with that key is not present ? Thanks in advance.
NDestiny
  • 1,133
  • 1
  • 12
  • 28
0
votes
1 answer

Error while using 'fitQmap' function in 'qmap' package in R

While using the fitQmap function in the R package qmap, I'm getting the follow error: x <- c(2179.759, 2154.498, 2130.792, 2173.525, 2121.694, 2110.078, 2112.477, 2080.512, 2074.096, 2133.571, 2146.682, 2132.320, 2139.447, 2134.702, 2172.010,…
0
votes
0 answers

QMap with custom class fails to copy

When i call the below function I gets the qmap empty. I read if my custom class is not derived from QObject and has copy constructor and assignment operator, it should work. QMap > mPayInOuts; QMap
A.J
  • 725
  • 10
  • 33
0
votes
1 answer

Get boundaries to come through on states

Edit 7 : After quite a bit of help, I've been able to get a map that is getting close to the results I need. But I still need to have the state boundaries come through on the map, but I can't figure it out. In order to make a reproducible example…
Vedda
  • 7,066
  • 6
  • 42
  • 77
0
votes
1 answer

How to get second value in QMap >

I have structure QMap > *map; Next I insert data: map = new QMap >; QMap *d = new QMap; d->insert("Name","Michal"); map->insert("QLineEdit",*d); if I…
MiMo
  • 124
  • 1
  • 2
  • 9
0
votes
4 answers

How to reverse the order of the same keys when inserted using insertMulti in QMAP?

I have a QMAP data structure. Now, I want to insert the QVariant type in the QMAP. The data is inserted based on the priority. For example priority 1, 2.. etc. These priority is the key in the QMAP. However, I can have the same key values - meaning…
dexterous
  • 6,422
  • 12
  • 51
  • 99