[Qt-interest] Using qSort with lists of QPointers

Stephen Kelly steveire at gmail.com
Mon Sep 6 01:55:37 CEST 2010


Ellen Kestrel wrote:

> bool ListManager::objPrecedes (QPointer<MyClass> c1, QPointer<MyClass> c2)
> {
> return c1->comesBefore (c2);
> }
> 


struct ListManagerLessThan 
{
  bool operator()(QPointer<MyClass> c1, QPointer<MyClass> c2) const
  {
    return c1->comesBefore (c2);
  }
};

...

ListManagerLessThan lt;
qSort(list.begin(), list.end(), lt);


?

All the best,

Steve.




More information about the Qt-interest-old mailing list