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

QMap does not name a type

I'm starting out with Qt Creator and I'm working on mapping some key value pairs (AWG wire gauge sizes as keys and the diameter as value). In using QMap to create the map, I'm getting compile errors of 'awg_map does not name a type'. Can anyone…
Max
  • 95
  • 1
  • 13
-1
votes
1 answer

How can I make a QMap object emit a signal when `QMap::insert(...)` is called?

Pretty straightforward question. QMap does not inherit QObject, so I'd like to know if there is an easy Qt Way of making it emit mySignal(MyEnum state). If you are asking why I do not just emit a signal in my code when I call the function…
Anon
  • 2,267
  • 3
  • 34
  • 51
-1
votes
1 answer

Get The Row,Column values from a cell in QT

I have a problem, i want to return the selected Rows values, and the columns separately, i found a method to return both of them using the function cell(row, column), but i want to get them separately Here is my code : QTableWidgetItem *c = new…
-1
votes
2 answers

Changing a map content inside const function

I get an iterator from a const QMap using QMap::find(), and through that iterator, I can change the content of the map. In my opinion this is a violation of the logical constness of the object. Am I wrong? Is this allowed because compiler cannot…
-1
votes
1 answer

QMap with multifields

I need to store some data of table type like a QTableWidget but without a GUI. Something along the line of the following code: QMap Is there a way of achieve this in Qt? My Qt version is 5.3.
-1
votes
1 answer

Creating a QLineEdit Widget Which Knows Which Tab It Belongs To

Question How do I make it so that a widget knows which tab "address" it belongs to with the eventual purpose of propagating this information to a signal? Background All of this below code is done in the same object hence why I can use this as a…
fiz
  • 906
  • 3
  • 14
  • 38
-1
votes
1 answer

QMap iterator crash

So I've been working on a small project in which I want to read the EXIF data from a JPEG, store it in a map to later on display it in a QListView. So in order to get the exif data I have this void CImageMeta::cacheEXIF() { if(!isValid())…
rfreytag
  • 1,203
  • 11
  • 18
-1
votes
3 answers

QMap strange behaviour

After inizialized a QMap in the .h file in this way QMap *map; When I declare in the constructor map = new QMap; map["one"] = "foobar"; error: invalid types 'QMap*[const char [4]]' for array subscript …
user3713179
  • 361
  • 3
  • 12
-2
votes
1 answer

Unobvious behavior of the QMap().begin() function in Qt C++

Let's look at the simple code with QMap iterator. #include #include int main() { QMap> testA; testA [0][0] = 1; QMap::iterator _iterTestA; for(_iterTestA = testA[1].begin();…
1 2 3
12
13