PDA

View Full Version : sorting Data in QTable



sosanjay
23rd October 2009, 11:02
hi...
I'm successfully inserting data in QTable.
I'm having 12 column.

In 1 column i'm storing QDate in Qstring format.

the question is can i sort the table through Datewise.

this is code which is working perfectly while sorting table with integer.



tableWidget->sortByColumn(4,Qt::DescendingOrder);

sosanjay
23rd October 2009, 12:40
Can anyone tell me that
How I sort the table data in Datewise or Current Timewise?

TMan
23rd October 2009, 15:31
I suppose Qt is sorting on strings in your tables, so that won't work obviously. I have no real experience with this, but perhaps you can insert a hidden column, assign each column a numerical value for each date, and sort using the hidden column?

sosanjay
23rd October 2009, 15:40
Can you send me the snippets code example of Hidden Column.
Actually I am working on TableWidgets first time so I have not so much idea.

Please send me some useful link or data.

TMan
23rd October 2009, 16:20
I have no snippets on hidden column. Check out the docs for qtableview.

nikhilqt
23rd October 2009, 17:42
this might help you,

http://www.qtcentre.org/forum/f-qt-programming-2/t-the-precision-range-of-double-22273.html

jbiloba
24th October 2009, 02:21
Try to use the date ansi format that is:

YYYYMMDD

YYYYY = year
MM = month
DD = day

its the best way for sorting date.
Take a look to QDate class