Ya nice work! For the checkbox, if you are only concerned with on/off, then use isChecked(). Like Marcus said, checkState() would be relevant if you were also considering half checked and you would want to use the constants to test it instead of int/bool
A couple notes on your gist: - 34: I would recommend not limiting it to a specific column in this method. The table view has a way to set the delegate for a given column. This way you can reuse this delegate in multiple places, regardless of its intended column. It would just care about the type of data/state it is going to represent. - 44: You can actually get the data right off the QModelIndex: index. data(QtCore.Qt.CheckStateRole) These kinds of things can actually save you a lot of calls, since in the Qt model/view world, you have to expect that your methods will get called a bazillion times a second. Its not really relevant for performance in this particular method since it does get called often, but its a good thing to know when you are inside something like data() which is called insanely often. - 46 and 195: Don't compare the CheckStateRole against an int. Use the constants: QtCore.Qt.Checked - 98: Move your list of columns that you define every time into a private constant set for your class: self._checkBoxColumns = set([4,5,6,7,8]) That way you can test membership quickly, without creating the list every time, and have a nice place in your constructor to set those. - 154: Are you sure this is correct to create and return a widget for the EditRole? Although I don't see it really being used anywhere. But ya, props on figuring it out. Like I said, you are delving into one of the most complex areas of Qt ;-) On Sat, Feb 15, 2014 at 5:08 AM, Marcus Ottosson <[email protected]>wrote: > Wow, great job! It certainly looks like you have got the delegate under > control. > > > -> is there an alignment method to use on the cells of the QtableView? >> > > Yes, but not in the QTableView, that would be the responsibility of the > model. As part of its data() method, one of the role asked for be an > alignment role of sorts, for which you can return a Qt.AlignLeft etc like > usual. > > You could possibly subclass the view to take control over this, I am not > sure. > > >> -> Why the result of QCheckBox.checkState() is returning 0 or 2 instead >> of 0(unchecked) and 1(checked)? >> > > Because the checkbox can have three states - off (0), half-on (1) and > full-on (2). > > >> -> How to get the selected row in the QTableView ? >> > > Have a look at the > QItemSelectionModel<http://qt-project.org/doc/qt-5/qitemselectionmodel.html#details>, > there should be one within your QTableView. > > Best, > Marcus > > -- > 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/CAFRtmOD%3D7nqvQDg8Zcf2SxgLiMqJSLi-QgvLQS3dJEooG79u%2BQ%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/CAPGFgA2NTWk2HEf6QJMAQLwVSzouutDU9tua3SfKUTMH8FnhHg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
