Skip to content

Instantly share code, notes, and snippets.

@raghunayak
Created March 26, 2021 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raghunayak/f277e0defbfd8b2735e4f0d38bfc6c38 to your computer and use it in GitHub Desktop.
Save raghunayak/f277e0defbfd8b2735e4f0d38bfc6c38 to your computer and use it in GitHub Desktop.
Nested QMap example
#include <QMap>
#include <QString>
#include <QDebug>
int main(int argc, char *argv[])
{
enum VehicleManufacturer { Toyota, Holden };
enum VehicleType { HatchBack, Coupe, Sedan };
static const QMap<VehicleManufacturer, QMap<VehicleType, QString>> vehicleGroups {
{ VehicleManufacturer::Toyota, {
{ VehicleType::HatchBack, "Corolla" },
{ VehicleType::Sedan, "Camry" },
}
}, { VehicleManufacturer::Holden, {
{ VehicleType::Sedan, "Commodore" }
}
}
};
for (auto i : vehicleGroups.keys()) {
for (auto j : vehicleGroups[i].keys()) {
qDebug() << i << j << vehicleGroups[i][j];
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment