Details
-
Suggestion
-
Resolution: Unresolved
-
P5: Not important
-
None
-
5.7.0 Beta
-
None
Description
QDataWidgetMapper can not be used to bind any QGraphicsWidget embedded in a scene because it does not derive from QWidget. The documentation for QGraphicsWidget clearly states the reason why QGraphicsWidget does not inherit from QWidget. However, because QDataWidgetMapper only accepts QWidget mappings, it can not be used to map any widget or graphics item in a scene to a model.
It would be extremely useful if QDataWidgetMapper could be used to map graphical items in a scene to a model. Rather than adding an override to QDataWidgetMapper that accepts QGraphicsWidget, I would instead suggest that the override accept any QObject. The code would require very little refactoring to let QDataWidgetMapper bind a model to any arbitrary QObject properties.
Many users have had problems following the MVC pattern with QGraphicsScene, as a simple Google search makes clear:
https://www.google.com/?gws_rd=ssl#q=qgraphicsscene+model+view
This solution would solve this problem in a very straight forward way and require a lot less boilerplate from Qt users. The mapping of arbitrary QObject properties would also solve other niche areas of data binding and give classic Qt a much more feasible and robust means of data binding. Currently QML has the best data binding about as powerful as that offered by the .NET Framework.