Created
          March 26, 2021 11:03 
        
      - 
      
- 
        Save raghunayak/f277e0defbfd8b2735e4f0d38bfc6c38 to your computer and use it in GitHub Desktop. 
    Nested QMap example
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #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