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

Qt/C++ store parent methods for callback in a QMap

I have class A with methods like A1, A2, A3, etc each accepting identical parameters (a quint64 and a Qstring). Class A instantiates an object of class B which contains: typedef void (*TCallBackFunction)(quint64, QString); struct SCallBacks { …
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Is there a good practice in choosing a key for QMap/map

I need to use QMap just to keep a name of every connection. I was told that using a complex object like QTcpSocket as a key is not ideal since the way map compares key, it could think there is a duplicate while it isn't. So I…
Carol
  • 1,852
  • 26
  • 29
0
votes
1 answer

Keyboard layout switching in Qt, not Qt for embedded Linux

I am looking for a way to change the keyboard layout from within my Qt application. The application will run on a Linux kernel that doesn't support keyboard layout files, so Qt has to do everything concerning the mapping of the keyboard input. In…
Alex
  • 1,198
  • 2
  • 12
  • 26
0
votes
1 answer

QMap Insert only produces (error) 0 for Value and Key

I am having a problem inserting values into a QMap & I cannot figure out why. I have stripped my code right down to just make what I was trying to do work. The code is below: #include #include #include…
GPPK
  • 6,546
  • 4
  • 32
  • 57
0
votes
3 answers

access QMap element by its value not by its key

i want to access a QMap by it's value, but i don't want to iterate over it and find element with same value and use it's key, is there anyway to find QMap key by it's content? my code is : QMap >::iterator it; QMap…
mari
  • 417
  • 1
  • 6
  • 21
0
votes
3 answers

C++ variables don't get deleted at the end of the scope

I have the following code snippet (which basically discoveres a given folder recursively) and I don't understand something about memory management in C++: for(QFileInfo child : root.entryInfoList()) { if (child.isDir() && …
Peter
  • 1,047
  • 2
  • 18
  • 32
0
votes
1 answer

QMap Memory Error

I am doing one project in which I define a data types like below typedef QVector QFilterDataMap1D; typedef QMap QFilterDataMap2D; Then there is one class with the name of mono_data in which i have define this…
Saad Saadi
  • 1,031
  • 10
  • 26
0
votes
1 answer

GCC implicit conversion does not work with QMap and QMap&

How do I solve this: no known conversion for argument 5 from ‘QVariantMap {aka QMap}’ to ‘QVariantMap& {aka QMap&}’ gcc has this problem, MSVS does not, any idea?
Fabian
  • 1
0
votes
1 answer

Size of Qt containers: is QMap much larger than Qlist?

I am developing a software which maps information in 3D space. I use a container to hold this information. The container which I use is QList< QList< QMap > > > lidardata; which basically is a 2D grid representing a…
Francesco
  • 47
  • 1
  • 7
0
votes
1 answer

how to pass qmap from qt to javascript?

I could not find the sample code about passing qmap to javascript in qt. what I did ? I have connected a QObject to the javascript, and could able to emit the signal from qt app, which is captured by javascript. emit mydata(mapVariable); In…
Whoami
  • 13,930
  • 19
  • 84
  • 140
0
votes
1 answer

Use a QMap in a slot

I want to use a QMap that I have previously created to be used inside a slot. I've tried following this but it still did not work (I think I am just doing something stupid). Here is the code I am using. Constructor: QMap >…
pureooze
  • 156
  • 2
  • 11
0
votes
2 answers

Invalidate pointer values inside a QMap

I'm having what seems to be a weird issue, but it could be a quirk of how QMap's work and I just don't understand it. It's tough to summarize the problem, but I'll do my best. I have a class A, with a QMap mySomeTypeMap;. When…
roundtheworld
  • 2,651
  • 4
  • 32
  • 51
0
votes
1 answer

c++ Qt constant violation?

I have a class orders which has its instanced stored in a QMap/Map and has a Key:int, value:order pattern. Everything went fine until I started iterating through the map and accessing the functions of the class.First I was trying to print out the…
MrSSS16
  • 449
  • 3
  • 7
  • 21
-1
votes
1 answer

RRuntimeError: Error in loadNamespace(name) , displays there is no package called 'qmap'

I have tried importing qmap tool from R in Jupyter Notebook. All the functions that I have imported from R in Jupyter aren't giving any error however the qmap gives an error. How to solve this error of importing qmap, I have tried various methods…
-1
votes
2 answers

How do iterate QMap in other QMap

I look for on how to iterate a QMap in a other QMap like: QMap> map; Previously I used simple C++ std::map with the following code and that worked: for(auto it = this->liste.begin(); it != this->liste.end(); it++) { …
tutosfaciles48
  • 21
  • 1
  • 1
  • 5
1 2 3
12
13