Hello,
I have a QListWidget list that I first fill with QStrings, then sort the list, and then I want to get the QStrings back out of the list. I don't know how to do that. Can you help? Below is my code with comments.
//"number" and "features" are int values
//"dataTable" is a table of integers
//declare QListWidget list
//fill QListWidget list with entries
for(int k=0; k<number+1; k++)
{
for(int i=0; i<features+1; i++)
{
entry.append(dataTable[i][k]);
entry.append(",");
}
sList->insertItem(k, entry);
}
//sort list entries in ascending order
sList->sortItems(Qt::AscendingOrder);
//get the list entries back in the QString format
//I DON'T KNOW HOW??
//QString entry2 = sList.itemAt(1); for example won't work
//"number" and "features" are int values
//"dataTable" is a table of integers
//declare QListWidget list
QListWidget sList = new QListWidget(this);
//fill QListWidget list with entries
for(int k=0; k<number+1; k++)
{
QString entry;
for(int i=0; i<features+1; i++)
{
entry.append(dataTable[i][k]);
entry.append(",");
}
sList->insertItem(k, entry);
}
//sort list entries in ascending order
sList->sortItems(Qt::AscendingOrder);
//get the list entries back in the QString format
//I DON'T KNOW HOW??
//QString entry2 = sList.itemAt(1); for example won't work
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks