[Qt-interest] Is it a stupid way for sorting?
M. Bashir Al-Noimi
mbnoimi at gmx.com
Wed Apr 21 20:42:22 CEST 2010
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 :-[ )?*
QStringListsortPatterns(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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100421/75bcf431/attachment.html
More information about the Qt-interest-old
mailing list