PDA

View Full Version : Class for mapping input widgets



Hostel
13th September 2011, 00:32
I'm making a widget for mapping a QRecord to input widgets. I want to that this new class will be similar in use with QDataWidgetMapper. I create a method


addMapping( QWidget* _widget, int _field );


In this method I want to set a value from record to input control(_widget). How can I do this in right way? My only thing is to make in method a series of dynamic_cast's to discover what a input widget is under _widget pointer. The same issue I have with reading values from input widgets to record - there again I need to know of type widget because I need read value. How to resolve this situation in elegant way?

ChrisW67
13th September 2011, 05:01
I believe that QDataWidgetMapper uses the Qt property system and reads/writes the USER property for most widgets. Have a look at the source.

wysota
13th September 2011, 09:21
To be more exact it uses a QAbstractItemDelegate and its setModelData() and setEditorData() calls that do what Chris said (manipulate the USER property).