[PyKDE] PyQT 4.x Display Roles

Matt Chambers chambers at imageworks.com
Wed Oct 11 21:10:34 BST 2006


Andreas Pakulat wrote:
> On 10.10.06 21:19:59, M.Chambers wrote:
>   
>> How can I disable some that I'm not using?  Seems like a waste to call
>> data() that many times.  I'm using the model view stuff and its very
>> slow compared to Qt3.
>>     
>
> You can't or at least you can't with the built-in Q*Views. You'd have to
> write your own view class that only asks for the roles you need.
>
> Also for speeding things up, try to check the role parameter as one of
> the first things and return an empty QVariant() if it is uninteresting.
>
> If that's still to slow get a profiling tool and check where the time is
> really spend.
>
> Andreas
>
>   
I ended up making a single QVariant and return that over and over again, 
helped to speed it up:

    def data(self, index, role):

        if role != DISPLAY_ROLE:
            return EMPTY_VARIANT
       
        if not index.isValid():
            return EMPTY_VARIANT

        el = index.internalPointer()
        return QtCore.QVariant( el.get(self.__columns[index.column()][1]) )


-- 
*Matt Chambers <chambers at imageworks.com>*
*Sony Pictures Imageworks*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20061011/545da6bf/attachment.html


More information about the PyQt mailing list