[PyQt] QListView SelectAll Checkbox

Sherif Shehab Aldin silentquote at gmail.com
Sun Jan 8 01:37:46 GMT 2012


Hi,

I have a QListView, I also have a separate checkbox to do selectAll,
deselectAll functionality, and It's working. but  I am missing one thing,
when I do selectAll, then deselect one item, The SelectAll checkbox should
be cleared. I have been trying to figure out a way to do that but can't
find the right way to do It.

Here is what I have done so far:

I have conntected the listView.selectionModel() 'selectionChanged' signal
to toggle_groups_checkbox, In there I try to print the count of deselected
items, and if it's more than 0 I clear the checkbox, but printing the count
of deselected_items is not accurate, when I do selectAll it prints many
values, one of them deselectedItems  is 1... that would make me clear the
checkbox, which is wrong. I think there is a better way to do that, so any
guidance would be appreciated.

self.connect(self.ui.listView_gateway_groups.selectionModel (),
SIGNAL("selectionChanged(const QItemSelection&,const QItemSelection&)"),
                    self.toggle_groups_checkbox)

def toggle_groups_checkbox(self, set_selection, clear_selection):
        print set_selection.count()
        print clear_selection.count()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120108/eab6766b/attachment.html>


More information about the PyQt mailing list