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
0 answers

QMap insert/insertMulti

I am using the Qt5 addin with visual studio 2010. I am trying to populate a QMap on the heap with a char ID and QWidget* value as well as populate a QVBoxLayout with the QWidget*. I get a run time break from a QMap call of detch inside the insert…
Mike
  • 190
  • 7
0
votes
1 answer

Function pointer from QMap

I'm trying to implement factory method pattern in my QT project following this example: https://www.codeproject.com/Articles/363338/Factory-Pattern-in-Cplusplus #include #include class IAnimal { public: virtual int…
Agrowal
  • 1
  • 1
0
votes
1 answer

How to register a QMap inside of a QList as a Meta Type in QtScript?

I am looking at having a QList> object passed from my Qt code to a JavaScript file and wondering how to properly handle the qScriptRegisterMetaType portion of the code. Currently I am looking at having my Script value…
0
votes
2 answers

Qt - how to map ,map coordinates to image pixel in an scene

I have created an Scene in Qt where i took the an image from open street map[.png] and placed it into the Scene . I have also exported its coordinates in an another file .My Question is how do I map my image pixel with the map coordinates. basically…
Verve Innovation
  • 2,006
  • 6
  • 29
  • 48
0
votes
1 answer

Qt Command Pattern QHash/QMap

I've recently implemented a command design pattern in Java with the use of: private HashMap commands; Where Component is any Java Component (JButton, JMenuItem, ...) and CommandInterface is an interface for my…
chrizbee
  • 145
  • 1
  • 13
0
votes
1 answer

QMap operator <()

I'm not sure to understand the docs correctly. I want to define my own <() operator for QMultiMap in order to use a custom type and define a specific values(const Key &key) behavior. The desired behavior is to retrieve all the values that have the…
Mark
  • 4,338
  • 7
  • 58
  • 120
0
votes
1 answer

QMap doesn't insert when < operator compares two identical objects

I'm trying to learn Qt. I experienced some issues but generally I find the solution by googling. But this afternoon I had an issue with QMap and I don't understand the problem. I've created a class File and I overrided the operator< in order to be…
naslami
  • 345
  • 2
  • 4
  • 12
0
votes
0 answers

Error using enums as value in QMaps on windows

I have an application I wrote on OSX which works when complied on OSX but fails to compile on windows. In particular it gives me problems when I try to declare a QMap which has an enum as value. So when I try to do this: QMap
Nicolo Castro
  • 195
  • 1
  • 3
  • 8
0
votes
1 answer

Draw multiple lines on qmap for a country

I would like to map multiple connections like this, but on a much more precise level (country). To do so, I would like to combine the qmap package and the packages used in the link, but it doesn't work out. Anyone got som ideas? I'm already trying…
user7905457
0
votes
1 answer

How can I use a QMap::const_iterator as a pointer?

How can I use a QMap::const_iterator as a pointer? QMap::const_iterator *i = map -> constBegin(); while (i != map -> constEnd()) { qDebug() << i -> key() << ": " << i -> value(); …
Program-Me-Rev
  • 6,184
  • 18
  • 58
  • 142
0
votes
2 answers

How to use a QMap in an interface

I'm trying to use a QMap in my class, but I get the error: /* path */.h:18: error: template argument required for ‘class QMap’ class QMap; ^~~~ The implementation class QMap; class MappingInterface { public: virtual…
Program-Me-Rev
  • 6,184
  • 18
  • 58
  • 142
0
votes
1 answer

iterate over QMap starting from given key

I have a qmap list, map.insert(1,"One"); map.insert(2,"Two"); map.insert(3,"Three"); map.insert(4,"Four"); map.insert(5,"five"); map.insert(5.5,"five.five"); map.insert(7,"five.five"); my interval is [2,5.1] I need to start from 2 till i…
0
votes
3 answers

Getting Value out of Nested QMap

I have a nested QMap QMap > map and a temporary QMap QMap tmpMap I need to fill the temporary QMap with the inner QMap's keys and values so I can loop through and output all the values of the…
TheIntern
  • 13
  • 7
0
votes
1 answer

Transmit QMap by QMimeData

Is any ideas how i can transmit QMap in Drag and Drop mode by using QMimeData? Now i convert QMap into QString like this: "key1:value1;key2:value2;...keyN:valueN" and assigned it to QMimeData::setText(). Then on dropEvent() i…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
0
votes
2 answers

Qmap aspect ratio

If I map # install.packages("ggmap") library(ggmap) qmap("USA", zoom = 4) I get a map of the US, but it but a bit of Maine and a bit of the west coast cut out. It also extends between the artic circle and Honduras. Is there a way with qmap or…
Raghu Ramachandran
  • 157
  • 1
  • 1
  • 9