PDA

View Full Version : QWidget and type



nowire75
8th November 2007, 19:33
Hi,

thanks for the big help that I receive here.
Now I have this problem:
in a QWidget array, I have more type of widget. For example widget[0] is QDoubleSpinBox, widget[1] is QLineEdit, and widget[2] is QSpinBox.
Is possible know the type of widget by code?
I need this because if the widget is QSpinBox I make same operation, if is QLineEdit other operations...

Thanks,
Nowire

jpn
8th November 2007, 19:55
if (QSpinBox* spinBox = dynamic_cast<QSpinBox*>(list.at(i)))
{
spinBox->doSomething();
}
else if (QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(list.at(i)))
{
lineEdit ->doSomethingElse();
}