Good morning,
even if I know that it is not the correct technique to do, I need to instantiate a different type of dialogue depending on the parameter passed on the command line.

Something like that:

Qt Code:
  1. enum class FILTERS
  2. {
  3. AIRPORTS = 1,
  4. FDDI = 2,
  5. RRT = 3,
  6. TARGET = 4,
  7. TRACK = 5
  8. };
  9.  
  10. int main (int argc, char ** argv)
  11. {
  12. QApplication app(argc, argv);
  13.  
  14. QMap<QString, FILTERS> filterMap;
  15. filterMap["airports"] = FILTERS::AIRPORTS;
  16. filterMap["fddi"] = FILTERS::FDDI;
  17. filterMap["rrt"] = FILTERS::RRT;
  18. filterMap["target"] = FILTERS::TARGET;
  19. filterMap["track"] = FILTERS::TRACK;
  20.  
  21. QCommandLineParser parser;
  22. parser.setApplicationDescription(QApplication::translate("main", "Call the right filter"));
  23. parser.addHelpOption();
  24.  
  25. QCommandLineOption filterTypeOption("t", QApplication::translate("main", "Specifies the type of filter to call"));
  26. parser.addOption(filterTypeOption);
  27.  
  28. parser.process(app);
  29.  
  30. QString filterType = parser.value(filterTypeOption);
  31. FILTERS filter = filterMap[filterType];
  32.  
  33. switch(filter)
  34. {
  35. case FILTERS::AIRPORTS:
  36. AirportsDialog dialog;
  37. break;
  38.  
  39. case FILTERS::FDDI:
  40. FDDIDialog dialog;
  41. break;
  42.  
  43. case FILTERS::RRT:
  44. RRTDialog dialog;
  45. break;
  46.  
  47. case FILTERS::TARGET:
  48. TargetDialog dialog;
  49. break;
  50.  
  51. case FILTERS::TRACK;
  52. TrackDialog dialog;
  53. break;
  54. }
  55.  
  56. dialog.show();
  57. int ret = app.exec();
  58. return ret;
  59. }
To copy to clipboard, switch view to plain text mode 

An example of a call will be:
dialog_caller -t rrt
or

dialog_caller -t airports
Is there a better way to achieve this behavior? The different dialogs are totally different from each other.
By instancing the dialog in the switch it will be removed once you exit from the switch?

How to make it remain active until the end of the program?