Qt-interest Archive, June 2007
Re: QStandardItemModel, QTableView: sorting a double value
Message 1 in thread
Thanks a lot for helping !!
I'll try this out ! ;-)
Heiko
Am 31.05.2007 um 18:03 schrieb Scott Aron Bloom:
>> -----Original Message-----
>> From: Justin Noel [mailto:justin@xxxxxxx]
>> Sent: Thursday, May 31, 2007 8:47 AM
>> To: QtList
>> Subject: Re: QStandardItemModel, QTableView: sorting a double value
>>
>> Scott Aron Bloom wrote:
>>> Little help on how :)
>>>
>>> First, derive from the model, and create a custom role, that returns
> in
>> the qvariant the double value.
>>>
>>> Then create a custom sort proxy model (derive from
>> QSortFilterProxyModel) and override the lessThan method.
>>>
>>> For the 2 QMI's sent in to the lessThan method, get the value of the
>> custom role you created (.data( CUSTOM_ROLE ))
>>>
>>> Set the standard model as the soruce for the proxy model.
>>>
>>> Set the proxy as the model for the view...
>>>
>>> Done.
>>>
>>>
>>
>> You can also use QSortFilterProxy's setSortRole() property as long as
>> the variant type is something the standard lessThan() supports. There
> are:
>> QVariant::Int
>> QVariant::UInt
>> QVariant::LongLong
>> QVariant::ULongLong
>> QVariant::Double
>> QVariant::Char
>> QVariant::Date
>> QVariant::Time
>> QVariant::DateTime
>> QVariant::String
>>
>> Good Luck,
>> --Justin
> I really need to go update some of my code :)
>
> I always forget they made the sort/filter proxy a ton easier to use in
> 4.2 :)
>
> Scott
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 2 in thread
Wow !
this class (QSortFilterProxy) is very useful for me !
It makes many thinks easier and I see, that I must rewrite some code
to use this class very often ;-)
Thank you very much for giving me this tip Justin, you made my
day ! ;-))
And to all other: Thanks a lot too !
Have a nice weekend !
Heiko
Am 01.06.2007 um 07:37 schrieb Heiko Steindl:
> Thanks a lot for helping !!
>
> I'll try this out ! ;-)
>
> Heiko
>
> Am 31.05.2007 um 18:03 schrieb Scott Aron Bloom:
>
>>> -----Original Message-----
>>> From: Justin Noel [mailto:justin@xxxxxxx]
>>> Sent: Thursday, May 31, 2007 8:47 AM
>>> To: QtList
>>> Subject: Re: QStandardItemModel, QTableView: sorting a double value
>>>
>>> Scott Aron Bloom wrote:
>>>> Little help on how :)
>>>>
>>>> First, derive from the model, and create a custom role, that
>>>> returns
>> in
>>> the qvariant the double value.
>>>>
>>>> Then create a custom sort proxy model (derive from
>>> QSortFilterProxyModel) and override the lessThan method.
>>>>
>>>> For the 2 QMI's sent in to the lessThan method, get the value of
>>>> the
>>> custom role you created (.data( CUSTOM_ROLE ))
>>>>
>>>> Set the standard model as the soruce for the proxy model.
>>>>
>>>> Set the proxy as the model for the view...
>>>>
>>>> Done.
>>>>
>>>>
>>>
>>> You can also use QSortFilterProxy's setSortRole() property as
>>> long as
>>> the variant type is something the standard lessThan() supports.
>>> There
>> are:
>>> QVariant::Int
>>> QVariant::UInt
>>> QVariant::LongLong
>>> QVariant::ULongLong
>>> QVariant::Double
>>> QVariant::Char
>>> QVariant::Date
>>> QVariant::Time
>>> QVariant::DateTime
>>> QVariant::String
>>>
>>> Good Luck,
>>> --Justin
>> I really need to go update some of my code :)
>>
>> I always forget they made the sort/filter proxy a ton easier to
>> use in
>> 4.2 :)
>>
>> Scott
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]