It is probably because when its not a persistent editor, the view triggers
the completion of the edit as each cell loses focus and the editor goes
away. But when you are using persistent editors, the widget is always
there. The delegate/model never see any interaction. Only the check box is
seeing it.

You should see if it fixes the problem by connecting a signal from the
check box to commitData() on the delegate.

http://qt-project.org/doc/qt-4.8/qabstractitemdelegate.html#commitData

In your createEditor() after you make a new check box...

from functools import partial
...
checkbox.toggled.connect(partial(self.commitData, self))

That will tell the delegate that the checkbox has changed and the state
should be committed to the model.
I used a partial because we needed to wrap the editor attribute into the
callback. The toggle value from the signal will just get ignored.
 On Feb 20, 2014 11:51 PM, "Ricardo Viana" <[email protected]> wrote:

> Hi Marcus thank you for the help.
>
> I have managed to align everything now. widgets all centered. but now my
> model doesnt update with the
> data after i check the checkboxes, all the rest still working.
>
> code here: <https://gist.github.com/RicardoViana/9110907>
>
> It seems my setModelData function doesn´t work. it doesn't spit any errors
> so i can trace it.
> the checkboxes update nicely from the model so my guess is my input is not
> reaching the setData on the model.
>
>
> def setModelData(self, editor, model, index):
>
>
>       model.setData(index,self.checkBox.isChecked())
>
>
> this works.
>
> def setEditorData (self, editor, index):
>
>
>      getValue = index.model().data(index,QtCore.Qt.EditRole)
>
>      if getValue == True:
>
>          self.checkBox.setCheckState(QtCore.Qt.Checked)
>
>          self.container.setStyleSheet("background-color:#347545")
>
>      else:
>
>          self.checkBox.setCheckState(QtCore.Qt.Unchecked)
>
>          self.container.setStyleSheet("background-color:#7F2627")
>
> thank you
>
> best
> Ricardo
>
>
> Another thing im confused is if i should still use the checkStateRole or
> EditRole for the checkboxes
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/9b5e7e16-19bd-476a-9f4f-b71957b2693b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1y5sscM8b_UQuFfDFgbePcVKBX-ixeLnT1Q1d%3DVC_CCg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to