[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QComboBox insert policy
From: Tina I <tinaweb () bestemselv ! com>
Date: 2007-04-22 6:17:35
Message-ID: 462AFDFF.806 () bestemselv ! com
[Download RAW message or body]
David Boddie wrote:
> On Thursday 19 April 2007 12:53:08 +0200, Tina I wrote:
>
>
>> I have a QComboBox (Qt4) where I want to insert items alphabetically.
>>
>
> [...]
>
>
>> The problem is of course that the item is inserted at position 'select'
>> and not where it fits in the alphabet. And from the documentation I can
>> not find any insert methods that does not require the 'index'. Am I
>> missing something?
>>
>
> QComboBox doesn't provide any support for sorting itself. You could either
> sort the list in advance or, if you need the unsorted list elsewhere, you
> could use some technique for inserting the items in the correct order.
>
> If it doesn't seem like a wasteful operation, you could just sort a copy of
> the list and insert that into the combo box. You could even create a
> QStringList, sort it, and pass that into QComboBox::addItems().
>
> David
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
D'oh! I always seem to overcomplicate things when working with Qt.
list.sort() does the job perfectly...
Thanks!
Tina
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic