[PyKDE] Custom sorting function for the QListView widget

Fernando Jorge Silveira Filho fernando at land.ufrj.br
Sun Jul 4 14:36:00 BST 2004


Hi Detlev,

>Before you go through all the hassles implementing a C++ extension you 
>could try to preformat your numerical data (e.g. left padding with 
>blanks) when you create the QListViewItems and later on rely on the 
>native sort functions.
>
>Exchange the lines
>
>for i in range(1000):
>    item = MyQListViewItem(lst, "%s" % i)
>
>of your example with
>
>for i in range(1000):
>    item = QListViewItem(lst, "%4d" % i)
>
>  
>
I'm afraid that won't solve the entire problem in my case. In the 
simplified code I sent to the list I used integers just for the sake of 
simplicity. In the real app I'll be filling the table with arbitrarily 
precise real numbers (doubles). And I won't be able to pad the doubles 
with zeros in the end because they may be many orders of magnitude away 
from each other. The real numbers list should be like:

9.1123111202e+01
2.0001277853e-11

and so on...

Thanks for the suggestion anyway. I hadn't thought of that one before. :-)

About the C++ extension issue, how do I go about implementing an 
extension? Is there some sort of tutorial on this? I have to admit that 
I am still sort a Python newbie. I am willing to try it anyway, since I 
still think that if I can solve this on Python the final result will 
look a lot more "elegant" than a full C++ solution.

Regards,
Fernando




More information about the PyQt mailing list