Issue
mapper = QtGui.QDataWidgetMapper()
mapper.setModel(my_table_model)
mapper.addMapping(widgetA, 0) #mapping widget to a column
mapper.addMapping(widgetB, 1) #mapping widget to a column
mapper.setItemDelegate(MyDelegateA(widgetA)) #Hmm. Where is the 'column' parameter?
mapper.setItemDelegate(MyDelegateB(widgetB)) #now itemDelegate is rewritten, MyDelegateB will be used
So... How do I set up mutiple delegates for a single QDataWidgetMapper
? As far as I understand there is no QDataWidgetMapper.setItemDelegateForColumn()
Or do I have to create some delegate factory, which will use appropriate delegates?
Thanks!
Solution
You have to use one single delegate and handle the way behavior of the different widgets in the setEditorData
and setModelData
functions of the delegate. For an example (C++ but straight forward) check this article from Qt Quarterly.
Answered By - pnezis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.