[SOLVED]List of QWidgets * and knowing what is what
I have a few code design problems.
I Have a list (QList) of widgets (QWidget *), where I've stored all widgets ( QComboBox, QLinedEdit ...) that go on a dialog whenever is called. Adding and showing them on a layout it's not a problem. But I'm stuck when I try to get data out of it. In Qt Docs I haven't found any methods provided for storing data.
Does Qt provide any way to do this, without packing another variable for class type and then switch-ing or if-ing through class types and then casting?
LE: better tell us what are you trying to achieve and maybe someone will give a better idea.
That's part of a problem solved :) .
No I only have to get data inputed by user out.
I'm trying to dynamically built forms based on XML data (done). That dialog is then shown when user double clicks on graphics item (done). When it closes it, data from widgets must processed.
It stops when I have to get data out of QWidget.
With metaObject() it's now easy to use a bunch of ifs, but if I add another widget, I need to fix code at few other places as well.
Look further trough "QMetaObject documentation":http://doc.qt.digia.com/qt/qmetaobject.html //see "invokeMethod":http://doc.qt.digia.com/qt/qmetaobject.html#invokeMethod
This methods solved quite a lot of trouble :) .
Marked as solved.
Also, widgets have properties, and one of these properties is marked the user property. That property will contain the value you need. You can find out and query the property you need using QMetaObject.