Bill
10th August 2009, 17:34
Hi,
I'm facing a problem which I can't overcome... In a for() loop I'm creating objects of 3 different classes depending on an if() statement:
if(type == "string")
{
QLineEdit *string = new QLineEdit(groupBox);
groupBox->layout()->addWidget(string);
}
else if(type == "date")
{
QDateEdit *date = new QDateEdit(groupBox);
groupBox->layout()->addWidget(date);
}
else if(type == "image")
{
QLabel *image = new QLabel("image",groupBox);
groupBox->layout()->addWidget(image);
}
Now it would be nice to have some sort of array of those objects with an ID key, so I can lookup a specific object depending on the ID and change it's contents. I've tried QHash, but I would end up with 3 or more class fields of type QHash<int, className*>.
Do you have any better suggestion?
Thanks in advance,
Regards,
Bill
I'm facing a problem which I can't overcome... In a for() loop I'm creating objects of 3 different classes depending on an if() statement:
if(type == "string")
{
QLineEdit *string = new QLineEdit(groupBox);
groupBox->layout()->addWidget(string);
}
else if(type == "date")
{
QDateEdit *date = new QDateEdit(groupBox);
groupBox->layout()->addWidget(date);
}
else if(type == "image")
{
QLabel *image = new QLabel("image",groupBox);
groupBox->layout()->addWidget(image);
}
Now it would be nice to have some sort of array of those objects with an ID key, so I can lookup a specific object depending on the ID and change it's contents. I've tried QHash, but I would end up with 3 or more class fields of type QHash<int, className*>.
Do you have any better suggestion?
Thanks in advance,
Regards,
Bill