Thanks for your response. I should have mentioned that I did think of creating my delegate for the data mapper (I have one for QTreeView). But after some analysis, I abandoned the idea. My tree view and to its right, the GUI/dialog with its 3 widgets, looks like this.
- Files | wFile: file2
|--file1 |
|--file2 | wUR1: xyz
|--file3 | wUR2: abc
The column count for Files index is 1, and row count is n, but column count for individual files is 0! Let's say each file file1, file2, ... has user role data ur1, ur2. The mapper and its delegate dFile attached to the widget wFile is for the selected file, but not the 2 widgets, say, wUR1, wUR2, that I will have for the user role data. I could try to use dFile to shuttle the data of wUR1, wUR2 back and forth from the model. I may be wrong but I think it can become challenging to connect dFile to editors of wUR1, wUR2.
So I thought I would derive MyUserRoleMapper from QDataWidgetMapper like so:
MyUserRoleMapper
::addURmapping( QWidget* wUR, UREnum urEnum
);
// and use as follows
myURmapper.addURMapping( wUR1, urEnum1 );
myURmapper.addURMapping( wUR2, urEnum2 );
class MyUserRoleMapper : public QDataWidgetMapper { ... };
MyUserRoleMapper::addURmapping( QWidget* wUR, UREnum urEnum ); // and use as follows
myURmapper.addURMapping( wUR1, urEnum1 );
myURmapper.addURMapping( wUR2, urEnum2 );
To copy to clipboard, switch view to plain text mode
The derived class will maintain the above mapping, and then whenever the current model index from the base class QDataWidgetMapper changes, populate data into user role widgets. Likewise when these widgets are edited, based on the editor losing focus, shuttle the data back to the model. I don't think I need a custom delegate here.
Would this work? Appreciate any feedback you may have. Thanks.
Bookmarks