I will have a function that places actions one by one into a "map" and then returns it.
The receiving function will use different "lists" to loop over that map.
Do you recommend QMap, QHash, std::map or std::unordered_map?
For short lived lists, with no inserts or removals, that will be used once in a ranged for loop,
do you recommend QList or std::vector?
I considered a simple array, but I want to just keep reusing the same variable name.
The lists will be used in combination with the map to created toolbars/menues in loops.
example idea:
vector<string> a_vector;
a_vector = {"a1", "a2", "a3"}
for (string str : a_vector)
{
a_map[str]->setCheckable(true);
menu->addAction(a_map[str]);
toolbar->addAction(a_map[str]);
}
... menu and toolbar change ...
a_vector = {"a4", "a5", "a6", "a7"}
for (string str : a_vector)
{
a_map[str]->setCheckable(true);
menu->addAction(a_map[str]);
toolbar->addAction(a_map[str]);
}
vector<string> a_vector;
a_vector = {"a1", "a2", "a3"}
for (string str : a_vector)
{
a_map[str]->setCheckable(true);
menu->addAction(a_map[str]);
toolbar->addAction(a_map[str]);
}
... menu and toolbar change ...
a_vector = {"a4", "a5", "a6", "a7"}
for (string str : a_vector)
{
a_map[str]->setCheckable(true);
menu->addAction(a_map[str]);
toolbar->addAction(a_map[str]);
}
To copy to clipboard, switch view to plain text mode
Bookmarks