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

william.crocker at analog.com william.crocker at analog.com
Wed Apr 21 19:58:32 CEST 2010


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



More information about the Qt-interest-old mailing list