I'm trying to write a function, which gets a List containing some QWidget's from the UI. The function should take each widget, detect its Class and do some checks.
The Problem is, that I don't really know how to access e.g. the QLineEdit's functions when I'm in fact dealing with QWidget.
Is there a way to get this working? Or is there another completely different approach?
bool CLASS::inputValid(QList<QWidget *> widgetList) {
bool everythingValid = true;
foreach (QWidget *widget, widgetList) {
if (QString(widget->metaObject()->className()) == "QLineEdit") {
// check if text is empty
if(widget->text()->length() == 0) // I know this doesn't work this way
everythingValid = false;
}
else if (QString(widget->metaObject()->className()) == "QTextEdit") {
// check if text is empty
if(widget->text()->length() == 0) // I know this doesn't work this way
everythingValid = false;
}
}
return everythingValid;
}