[Qt-interest] Is it a stupid way for sorting?

M. Bashir Al-Noimi mbnoimi at gmx.com
Thu Apr 22 04:11:48 CEST 2010


Thanks William,

Actually I took this way because I don't know how I can make sort 
process by qSort (I found in Qt documentation something about QMap and 
qSort), so could you give me an example explains how to do that?

On 21/04/2010 07:58 م, william.crocker at analog.com wrote:
> See:
>
>       qSort ( RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan )
>       et. al.
> 	
> M. Bashir Al-Noimi wrote:
>    
>> Hi All,
>>
>> I want to sort QStringList by specific item count so I tried to use QMap
>> for it but I failed but I used QTableWidget instead but without viewing
>> it in the GUI, *is it correct way for sorting? it's slow (and stupid :-[ )?*
>>
>> QStringList sortPatterns(QStringList patterns)
>> {
>>      QStringList result;
>>      QTableWidget *table = new QTableWidget(patterns.count(), 2);
>>      for(int x=0; x<patterns.count(); x++)
>>      {
>>          int count = patterns[x].count("?");
>>          table->setItem(x, 0, new QTableWidgetItem(QString("%1").arg(count, 2, '0')));
>>          table->setItem(x, 1, new QTableWidgetItem(patterns[x]));
>>      }
>>      table->sortItems(0);
>>      for(int x=0; x<patterns.count(); x++)
>>          result<<table->item(x, 1)->text();
>>      return result;
>> }
>>
>>
>>
>> -- 
>> Best Regards
>> Muhammad Bashir Al-Noimi
>> My Blog: http://mbnoimi.net
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>      
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>    

-- 
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net




More information about the Qt-interest-old mailing list