[PyQt] check box controlers - tree View problem

David Boddie david at boddie.org.uk
Mon Jan 7 23:49:35 GMT 2008


On Fri, 28 Dec 2007 03:45:55 -0800 (PST), purest2 wrote:

> I am now trying to write a similar program, however the systems people have
> upgraded us to PYQT4.
>
> all the old classes are listed as out-of-date, so i am using the new stuff.
> i am using a treeView and the nodes are QStandardItems. it is easy enough
> to make them checkable:
>        
>         void setCheckable ( bool checkable )
>
> but I cant see any way of making them automatically controll the child
> nodes, and i dont see how i can write it myself as i cant even find a
> signal to tell me the state has changed.

QStandardItemModel's itemChanged() signal is what you're looking for:

http://www.riverbankcomputing.com/Docs/PyQt4/html/qstandarditemmodel.html#itemChanged

In the slot you connect to this signal, iterate over the QStandardItem
children and update their checked states with the setCheckState() method
as usual.

David




More information about the PyQt mailing list