PDA

View Full Version : QTreeView sorting



Jonny174
3rd May 2011, 07:34
Hi All.
I trying to use:


struct FLess : public std::binary_function<HASH, HASH, bool>
{
int Col;
static void setCol( int C );

inline bool operator()( const HASH &rec1, const HASH &rec2 )
{
return ( rec1.hash.value( Col ) < rec2.hash.value( Col ) );
}
};

In programm:


FLess::setCol( 5 );

if (order == Qt::AscendingOrder)
std::sort( Records[i].begin(), Records[i].end(), FLess() );

How make sort by Col?
Thanks.

franz
3rd May 2011, 07:48
What exactly do you want to achieve, and why do you want to achieve that (that might help in helping you).

Jonny174
3rd May 2011, 09:24
If I put number, for example 5 all works normally

return ( rec1.hash.value( 5 ) < rec2.hash.value( 5 ) );
I need to read out from a variable

return ( rec1.hash.value( SomeVariable ) < rec2.hash.value( SomeVariable ) );