Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, May 2008
Re: Using the qsort less than function


Message 1 in thread

Dear all

as I have exactly the same problem, I would like to know if there is
"a right way" to solve this... looking on google I found something
about using the std::mem_fun_ref() adapter but it seems not to work
for me.

Here is a piece of my code:

----------------

void NPlanePathMap::sortByIndex(Qt::SortOrder sortorder)

{
   if (sortorder==Qt::AscendingOrder)
     qSort(order.begin(), order.end(),
std::mem_fun_ref(&NPlanePathMap::indexLessThan) );
      else
     qSort(order.begin(), order.end(),
std::mem_fun_ref(&NPlanePathMap::indexGreatherThan) );
}

bool NPlanePathMap::indexLessThan(const QString& _uuid1, const QString& _uuid2)

{
  ...
  return (_index1 < _index2);
}

bool NPlanePathMap::indexGreatherThan(const QString& _uuid1, const
QString& _uuid2)

{
  ...
  return (_index1 > _index2);
}

error is

error: no matching function for call to 'mem_fun_ref(bool
(NPlanePathMap::*)(const QString&, const QString&))'

  thanks a lot for any idea

            Andy


On 3/17/08, Kai Koehne <kai.koehne@xxxxxxxxxxxxx> wrote:
> André Somers wrote:
>> [...]
>> bool PatentDataExtractor::biblioNodeLessThan(const QDomElement& e1,
>> const QDomElement& e2) {
>>     //we always put the biblioentry of the document we were looking
>> for on top
>>     if (e1.elementsByTagName("B111EP").at(0).toElement().text() ==
>> m_magicSortKey)
>>         return true;
>>     if (e2.elementsByTagName("B111EP").at(0).toElement().text() ==
>> m_magicSortKey)
>>         return false;
>>
>>                // .... and so on
>> }
>> [...]
> How about making the method a non-member friend of the class? Have not
> tried it, though.
>
> Regards
>
> Kai Koehne
>
> --
> 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 ]