PDA

View Full Version : qtableview sort question?



yunpeng880
3rd March 2009, 03:29
i need sort by columen of qtableview,but qtableview sort by char ,but i need sory by int,
for example:
a columen data is : 1, 2, 10 , it is 1,10,2 if sort by char,but i need 1,2,10 .
can somebody holp me? thanks

aamer4yu
3rd March 2009, 06:14
Are you using QSortFilterProxyModel ?
If yes you need to override QSortFilterProxyModel::lessThan ..

if you are not using QSortFilterProxyModel you must be using some model...
You will need to override QAbstractItemModel::sort.

But it will be preferable that you use QSortFilterProxyModel and override the lessThan function. You wont have to alter your model :)

yunpeng880
3rd March 2009, 09:28
Are you using QSortFilterProxyModel ?
If yes you need to override QSortFilterProxyModel::lessThan ..

if you are not using QSortFilterProxyModel you must be using some model...
You will need to override QAbstractItemModel::sort.

But it will be preferable that you use QSortFilterProxyModel and override the lessThan function. You wont have to alter your model :)

thank you very much,i am success follow your way .
but i run into other question : i want some column header do't click,but i get just headerview ,do't make some column header do't click.
hope you help me,thanks