in my code using several qt widget classes I ses code like this:

} else if (caMenu *widget = qobject_cast<caMenu *>(w)) {
//qDebug() << "we have a menu";

if(data.edata.connected) {
// set no connection color
} else {
widget->setAlarmColors(NOTCONNECTED);
widget->setProperty("Connect", false);
}
widget->setAccessW(data.edata.accessW);

// choice ================================================== ================================================== ==============
} else if (caChoice *widget = qobject_cast<caChoice *>(w)) {
//qDebug() << "we have a choiceButton" << String << value;

if(data.edata.connected) {
// set no connection color
} else {
widget->setAlarmColors(NOTCONNECTED);
widget->setProperty("Connect", false);
}
widget->setAccessW(data.edata.accessW);

} else if .....



===============================
how could one call a routine using the same code with the same methods after dynamic casting ?