 Hey everybody, this is Brian. Welcome to the 40th Qt Tutorial with C++ and GoA programming. Today we're going to be covering the QMap. Now if you look in the documentation it says the QMap class is a template class that provides a skip list based dictionary. What does that mean? Well, what it means is it provides a key value pair. So you enter an item, but it has a key. For example, a records of employees. You have an employee ID number and the employee name. And that's kind of what we're going to build today. So let's just go File, New, Cue Console, and we'll say Maps, Test. And let's just throw this in the usual location. All right, now first thing we have to do is add some includes here. So QMap, All right. Now let's actually make our map here. So we'll say QMap. And we want an integer for the employee ID and we'll say a Q string for the name. Let's call this employees. There we go. All right, we've got our map. Now we need to populate it. So let me say employees, insert. You notice there's an insert and an insert multi. What insert will do is add it and if it exists, it'll override it. And insert multi will add a new item to it. So let's say insert. And the key we'll say one is Bob. And we'll say two is Chad. Let me get this lined up here. Three is Mary. And let's just print these out for each. And I in employees. And you want, you want to search the keys. Remember, this is a key value pair. So you want to grab all the instances of the keys and iterate through those. Say Q to bug. And let's just compile and run this and see what happens. Sure enough, we have Bob Chad, Mary. So let's actually change Mary's ID to a one and see what happens here. You notice how we only have Mary Chad, because remember, we're doing an insert. The insert, if it already exists, will override it. So let's say three. And let's just for the sake of experimentation here, let's try the insert multi just to see what happens. Insert multi and we want to take one and change that to say Amy. Now you notice how Bob has not been changed to Amy and it added a second Amy. So in case you're wondering, that's what happens when you do the insert multi. Let's just get rid of Amy here. Now let's say you want to actually iterate over this list and discover the keys and the values. So what you need is a Q map iterator. And you need to give it the same, same template. So we'll say Q string. And we'll call this Iter. And it's going to iterate over the employees list. So say while Iter has next, we'll say Iter next. So we'll just move to the next location here. We're just going to print some things out. We want to get the key. And let's get the name. So the key and the value are what we're really after here. We're just going to put an equal sign here so we can tell what's actually going on. Compile and run this. And you can see the for each macro just gives us the value where if we iterate through, we can get the key and value pairs. We can see that one is Bob, two is Cheds, three is Mary. All right. Pretty easy stuff, but a pretty, pretty powerful thing to use. All right. This is Brian. Thank you for watching. I hope you found this video educational and entertaining.