As long as I've understood your problem, you want different widget types to be added to the QMap.
Every Qt widget must be derived from QWidget, so you can create a map of QWidget pointers like this:
QMap<int, QWidget *> map;
To copy to clipboard, switch view to plain text mode
And then add different widgets, as per our example, I've added two different widgets QPushButton and QLabel
for(int i = 0; i < 7; i++)
{
map[i]->setGeometry(0, i * 50, 50, 50);
map[i]->setGeometry(100, i * 50, 50, 50);
}
for(int i = 0; i < 7; i++)
{
map[i] = new QPushButton(QString("Button %1").arg(i), this);
map[i]->setGeometry(0, i * 50, 50, 50);
map[i] = new QLabel(QString("Label %1").arg(i), this);
map[i]->setGeometry(100, i * 50, 50, 50);
}
To copy to clipboard, switch view to plain text mode
the setGeometry() method is used in this example just for display/cosmetic reasons.
Bookmarks