[PyQt] QTreeView and sorting

Reinaldo de Carvalho reinaldoc at gmail.com
Thu Nov 18 14:07:13 GMT 2010


On Thu, Nov 18, 2010 at 11:00 AM, dizou <di_zou at yahoo.com> wrote:
>
> So this is what I did:
>
> class TreeWidget(QTreeWidgetItem):
>    def __init__(self, parent=None):
>        QTreeWidgetItem.__init__(self, parent)
>    def key(self, col, asc):
>        print col
>        if col == 4:
>            path = self.text(col).latin1()
>            if path is not None and path.find("[") != -1:
>                pathIndex = path[path.rfind('[') + 1:len(path) - 1]
>                for i in range(20 - len(pathIndex)):
>                    pathIndex = '0' + pathIndex
>                path = self.GetObjectType() + pathIndex
>                print path
>                return path
>            else:
>                return self.text(col)
>        else:
>            return self.text(col)
>
> THen when I sort column 4 in my application, nothing changes and nothing is
> printed.
>

I said 'QListViewItem' reimplemented as 'QListViewItemXXxxxx', but you
must insert items with 'QListViewItemXXxxxx' on 'QTreeView'.

-- 
Reinaldo de Carvalho
http://korreio.sf.net
http://python-cyrus.sf.net

"While not fully understand a software, don't try to adapt this
software to the way you work, but rather yourself to the way the
software works" (myself)


More information about the PyQt mailing list