title: How to write a switch statement for strings in Qt?
body: <p>I need to create the equivalent of a switch/case statement for strings in C++ with Qt. I believe that the simplest way is something like this (pseudo code)</p>
  
  <pre><code>enum colours { red, green, blue };
  QString array[] colour_names = { "red", "green", "blue" };
  switch (color_names[user_string]) {
    case red: answer="Chose red";
    case green: answer="Chose green";
    case blue: answer="Chose blue";
    other: answer="Invalid choice";
  }
  </code></pre>
  
  <p>But this doesn't take advantage of some of the features of Qt.  I've read about QStringList's (to find the position of the string in a list of strings), and std:map (see <a href="https://stackoverflow.com/questions/207976/how-to-easily-map-c-enums-to-strings">How to easily map c++ enums to strings</a> which I don't fully understand).</p>
  
  <p>Is there a better way to do a switch on strings?</p>