Hi all,
I'm trying to implement a treeview for my application and a qdatawidgetmapper to map the model data into a properties widget to facilitate the modification of the model data. So far, everything works pretty well (thanks to the M. Summerfield books). I can use easily QLineEdit, QSpinBox and QComboBox widgets in the properties widget. Now, I would like to add a custom widget (a "color" widget) in this properties wigdet. Basically, this custom widget is a QLineEdit which can not be manually edited (readOnly mode activated) and a QPushButton that opens a QColorDialog instance when the button is clicked. Basically, I choose a color from the QColorDialog instance, and the name of the color is programmatically written into the QLineEdit. But I don't know how to do the mapping between the model and the properties widget (both in vizualization and edition). I tried few things I found on the internet, but nothing worked and I'm stucked (the examples on the internet are not numerous).
As an example would probably be clearer for you to understand my problemn, I've added a simple example in attachement of this message. The file contains several classes:
- ProjectNode : basic class which represents the node of my treeview. Contains 2 attributes used for the mapping onto the properties widget : name and color
- MyModel : custom model derived from QAbstractItemModel
- myTreeView : custom treeview
- PropertiesEditor : widget used to contain the data of the model (name and color)
- MyTreeWidget : widget that combine the myTreeView and my Properties Editor
- ColorWidget : custom widget evoked previously
So my problem is : how to map the data of a model onto a custom widget?
Any help would be greatly appreciated! Thanks in advance for your time
Vincent
Bookmarks