[PyKDE] how to use sip?

Vincent Wagelaar vincent at ricardis.tudelft.nl
Mon Feb 16 22:56:00 GMT 2004


On Monday 16 February 2004 22:12, Phil Thompson wrote:
> On Monday 16 February 2004 18:34, Uwe Mayer wrote:
> > Hi,
> >
> > sorry for this newbe question, but I just don't get sip running. I've
> > read the documentation and it doesn't say anything on how the structure
> > of the specification file.
> >
> > I downloaded, compiled and installed the newes version of sip: 4.0 RC2,
> > but sip even returns an error when I feed it any of the current PyQt .sid
> > files...:
> >
Maybe a bit off-topic, but it looks like you want to implement your own 
QListviewItem because of speed issues? I found it much easier to override the 
paintCell method and put the sorting value in the constructor. This way 
sorting stays speedy because the keys method stays in C++

example:

SpeedySortListViewItem(QListViewItem):
    def __init__(self, parent, items):
        QListViewItem.__init__(self, parent, items[0].lower(), 
items[1].lower())
        self.items = items

    def paintCell(self, p, cg, column, width, align):
        fm = p.fontMetrics()
        if self.isSelected():
            p.fillRect( 0, 0, width, self.height(), 
cg.brush(QColorGroup.Highlight ))
        else:
            p.fillRect( 0, 0, width, self.height(), 
cg.brush(QColorGroup.Base ))
        while fm.boundingRect(self.items[col]).width() > width:
            title = self.items[col][0:len(title)-4]+"..."
            if len(title) < 3:
                break
        p.drawText( 1, self.height()-4, self.items[col])

Cheers,
Vincent





More information about the PyQt mailing list