Make a checkbox list in Qt4 [PyQt4]

1k views Asked by At

Hey. I'm working on a project, porting a software from Qt3 to Qt4. Its in PyQt, but I'm okay taking answers as if I was working with C++ and the originals Qt4 libraries.

In the old code, a ListView with checkboxes are used. When trying to find the eqvalient for Qt4, nokia advise to not use Q3CheckListItem in new code, but there are no links to Qt4 eqvalient.

The solution seems to be having a delegate, and set that on the items. Like this myListView.setDelegate(delegate). The delegate is supposed to make the checkboxes and so on, but I can't find any examples or tutorials on this.

Thanks

1

There are 1 answers

1
AudioBubble On BEST ANSWER

You do not need delegates in order to have checkable items in your view, you just need to implement your model accordingly. Return Qt.ItemIsUserCheckable in the implementation of .flags(), and handle Qt.CheckStateRole in the implementations of .data() and .setData() (example).