Marcus makes a good point. Depending on how big your data set is, it can be easier to just use a TableWidget On Feb 22, 2014 8:52 AM, "Marcus Ottosson" <[email protected]> wrote:
> Just to note, I would re-consider whether or not you need the Model/View > framework for this task at all. A simple widget per row, with a widget per > column, might make life easier for you. > > The QAbstractItemModel and View are designed to handle thousands, if not > hundreds of thousands of items, which is why there are so many > abstractions, like the delegate and selection model. If you're working with > tens or hundreds, I would recommend going with plain widgets. > > > On 21 February 2014 19:36, Justin Israel <[email protected]> wrote: > >> It's trying to pass the toggled bool value as an extra argument. Probably >> should be more like this: >> >> def createEditor(self, parent , option, index): >> container = QtGui.QWidget(parent) >> layout = QtGui.QHBoxLayout() >> layout.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignCenter) >> layout.setContentsMargins(0, 0, 0, 0) >> container.setLayout(layout) >> checkBox = QtGui.QCheckBox(parent) >> checkBox.toggled.connect(partial(self._checkBoxToggled, checkBox)) >> layout.addWidget(checkBox) >> container.checkBox = checkBox >> return container >> >> def _checkBoxToggled(self, cbeckBox, *args, **kwargs): >> self.commitData.emit(checkBox) >> >> >> In addition to just pointing it at a custom slot, I have also changed >> your configuration a bit. I don't think the editor widget should be built >> and stored as members of the QItemDelegate. The view expects to use a >> single instance as a controller for more than just one cell in your table. >> That means you would be constantly replacing those references with newly >> created one every time it wants to create an editor. The interface methods >> tell you what editor widget you should be operating on, as a parameter. So >> that means setEditorData() and setModelData() should be receiving your >> container as the parameter and you would have to access your checkbox as: >> container.checkBox >> >> >> >> >> >> On Sat, Feb 22, 2014 at 1:47 AM, Ricardo Viana <[email protected]>wrote: >> >>> >>> Hi Justin >>> >>> i'm using standard Maya 2014 Pyside. guess is Qt4.8 >>> and i get another error now: >>> >>> # TypeError: commitData(QWidget*) only accepts 1 arguments, 3 given! >>> >>> >>> this is my full method in case something else is messing it: >>> >>> def createEditor(self, parent , option, index): >>> >>> self.container = QtGui.QWidget(parent) >>> layout = QtGui.QHBoxLayout() >>> >>> >>> layout.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignCenter) >>> layout.setContentsMargins(0, 0, 0, 0) >>> self.container.setLayout(layout) >>> self.checkBox = QtGui.QCheckBox(parent) >>> >>> >>> self.checkBox.toggled.connect(partial(self.commitData.emit, self)) >>> layout.addWidget(self.checkBox) >>> >>> >>> -- >>> 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/a614dba8-300e-4e95-9aae-17f5f2d43cd2%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/CAPGFgA3wn-t0Ckt306v8mwTxsPbrJUi84LPHJFmBYhVjcxm9Fg%40mail.gmail.com >> . >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > *Marcus Ottosson* > [email protected] > > -- > 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/CAFRtmOBxOsoco5u6uT6Ma-4JVRqoVNE%3DCdqgp3q%2BgqRYuHPUxg%40mail.gmail.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/CAPGFgA0GhNWz8KO-BYjx-knfT7j%2BWpQQaGjLTx9vO9moYPHtBw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
