Since Qt doesnt allow templates in their slots, I tried to do the following solution without success.
First a would like to create a list like this:
list commands =
0, "MyDashboard", DashBoard0
1, "MomsDashboard", Dashboard1
Dashboard 0 and 1 are both derived from widget
Lets say you have a QListWidget
where we add the strings in the list and then do the connection:
connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(addDashboard(QListWidgetItem*)));
void addDashboard(QListWidgetItem* item) {
int index = listWidget->row(item);
QWidget* widget = new typeof(command.atIndex(index).getType());
widget->show();
}
How would I create that list and store types just like you do in C# Type?