setAlarmColors
setProperty
setAccessW
what is the highest common class that has all of those methods? Lets say it is ClassX. If there isn't a common clsss then you should make an interface that does contain all the methods, then make all relevant classes inherit the interface (e.g. InterfaceX)
Then you just need one check:
if (ClassX *widget = qobject_cast<ClassX*>(w)) { // or InterfaceX
//qDebug() << "we have a ... not sure exactly what it is, but we know it has all the methods required...
if(data.edata.connected) {
// set no connection color
} else {
widget->setAlarmColors(NOTCONNECTED);
widget->setProperty("Connect", false);
}
widget->setAccessW(data.edata.accessW);
if (ClassX *widget = qobject_cast<ClassX*>(w)) { // or InterfaceX
//qDebug() << "we have a ... not sure exactly what it is, but we know it has all the methods required...
if(data.edata.connected) {
// set no connection color
} else {
widget->setAlarmColors(NOTCONNECTED);
widget->setProperty("Connect", false);
}
widget->setAccessW(data.edata.accessW);
To copy to clipboard, switch view to plain text mode
Bookmarks