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
1
vote
3 answers

Map - finding nearest value?

I am trying find nearest RGB value in QMap (I know it probably should be HSV, but that is not the problem). Here is what I got so far: it = images_map.find(current_rgb); if(it != images_map.begin()){ mi =…
Lord Vader
  • 13
  • 1
  • 3
1
vote
0 answers

Call pointer function registered inside QMap

I am currently writing a program that needs to call specific functions depending on a response byte sent by a serial device. Since the number of commands is somewhat large (~140 commands), I decided that the easier approach is o to relate the…
Alex Spataru
  • 1,197
  • 4
  • 14
  • 26
1
vote
2 answers

Issue with QMap and QDateTime as key

I'm using Qt 4.8.6 msvc 2010. I'm working on a software (this is done before Qt5, I'm supporting now). I have used a map: QMap dateTime After I insert some data to this map (for example with 5000 of data) and I want to get a…
Mosi
  • 1,178
  • 2
  • 12
  • 30
1
vote
1 answer

How to Iterate and Insert Items in Qmap?

I have a Qmap, contains some Objects( it is not free), for the sake of simplicity, imagine I want to add each object's child into the Qmap, so I have to Iterate the Qmap and insert each object's child on that. How I can do it? However, the real code…
hosh0425
  • 98
  • 1
  • 10
1
vote
1 answer

How to send QMap over socket?

I have a QMap object: QMap map; and I would like to send it over TCP socket. Do I have to convert it to JSON and then send it or?
Someone
  • 19
  • 4
1
vote
1 answer

QMap return Wrong QByteArray

I am using QMap < int, QByteArray> RegTable; (Seprate Class Variable) to storing Modbus Register Address and data received from Serial Port. Everything working fine, data read from the serial port and fill to the QByteArray correctly. qDebug() <<…
voidpointer
  • 301
  • 1
  • 8
1
vote
1 answer

QMultiMap And QDataStream

I saw in QtAssistant that QDataStream supports QMap and QMultiMap inherits QMap . Does Qt support QMultiMap for serialization with QDataStream ?
amiref
  • 3,181
  • 7
  • 38
  • 62
1
vote
1 answer

How to correctly remove an item from the map by key?

There is such a task: to delete items from the QMap by key. I do this with this code. QMap map; map.insert(0, "0"); map.insert(1, "1"); map.insert(2, "2"); map.insert(3, "3"); map.insert(4, "4"); map.insert(5, "5"); qDebug() <<…
Konstantin
  • 35
  • 1
  • 5
1
vote
2 answers

How to save QList into QSettings file

I have a large amount of data stored in a variable of type QList> and I need to save the variable to easily retrieve it. I want to save it into a file with QSettings but with no luck. How can I do this?
Alaa Agwa
  • 162
  • 1
  • 12
1
vote
0 answers

QMap::clear() crash

I'm running Qt-4.8.6 on Linux i686 I have a QMap mymap; and when I simply call mymap.clear(); the program crashes with stacktrace ... #7 #8 0x0806f50c in QBasicAtomicInt::deref (this=0x34) at…
1
vote
1 answer

Bias correction of raster climate data (qmap) - Error in formula

I am trying to apply a bias-correction function on some gridded climate data (observed and modelled projections). The qmap package has functions to perform bias correction on climate data, I am trying to run the…
Gianca
  • 109
  • 10
1
vote
2 answers

Qt QMap ignores insert command

I've a question that couldn't find anywhere. I have a QMap that's ignoring the QMap.insert(Key, Value) command. Here's the code: //gets the selected problem index on the ProblemList int selProblem = ui->tree_projects->currentItem()->data(0,…
1
vote
1 answer

how to store this info in qt? arraylist-ish ?

new bee here. I am sorry if there are similar questions but i just dont even know how to ask it properly. the thing is, i have to do some project for the uni and i am stuck now. i am getting info through udp and need to store the yield info to pass…
Ahmet Bat
  • 13
  • 5
1
vote
2 answers

basic use of QMap

This is my first time using QMap and I don't know what I'm doing wrong. #include QMap name_sec_age; name_sec_age.insert("willy", 593381460); my errors are: "unknown type name 'name_sec_age'" and "expected unqualified…
Life4ants
  • 683
  • 2
  • 8
  • 24
1
vote
1 answer

How to find the index of a specific row in QMap based QAbstractListModel?

I have a class derived from QAbstractListModel based on a QMap which I am visualizing with ListView in qml. Some time during my applications running time I am removing some items from this map based on it's QUuid. When I am…
Silex
  • 2,583
  • 3
  • 35
  • 59