[PyQt] example

Brian Kelley kelley at eyesopen.com
Mon Mar 2 14:23:11 GMT 2009


If you are using a ListWidget, you can add a checkbox as follows:

        item = QtGui.QListWidgetItem(text)
        item.setCheckState(QtCore.Qt.Checked)
        item.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable |
                                  QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )


It is slightly more complicated when using your own model, you have to implement the CheckStateRole in the data and setdata methods.

I.e. In data, return Qt.Checked or Unchecked when returning the CheckStateRole for an index.

Brian

On 3/2/09 12:48 AM, "Milan Hemžal" <001g at email.cz> wrote:

Hi,

pls., do you have nobody example, howto create and use checkbox in listview?

Thank's

Milan
_______________________________________________
PyQt mailing list    PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090302/d5e79563/attachment.html


More information about the PyQt mailing list