As I considered the order to be important I thought of using a QMap that enables me to store each Button with an integer.
If the order of the buttons is the same as the order in which they are added to the container, then QList would probably be better and simpler to use.
EDIT:
in your original post your code to extract the values from the list is correct.
But you are doing someting else wrong:
//QPushButton button ("Hello"); //button is allocated on the stack, and it gets destroyed at the end of the scope, probably a method.
//It should be:
//QPushButton button ("Hello"); //button is allocated on the stack, and it gets destroyed at the end of the scope, probably a method.
//It should be:
mapButtons->insert(10, new QPushButton("Hello",this));
To copy to clipboard, switch view to plain text mode
Bookmarks