Hi,
I'm trying to put the contents of a QTreeWidget in a QMultiMap but when I'm checking the result it seems only the first row had been inserted.
Here's my code:
QMultiMap<int, QString> mainInputWidget::returnTravelTableData()
{
QMultiMap<int, QString> rowStrings;
for (int row = 0; row < ui.MItravelTreeWidget->topLevelItemCount(); ++row)
{
for (int column = ui.MItravelTreeWidget->columnCount() - 1; column >= 0; --column)
{
qDebug() << "column" << column;
qDebug() << "row" << row;
rowStrings.insert(row, ui.MItravelTreeWidget->itemAt(row,column)->text(column));
}
}
return rowStrings;
}
QMultiMap<int, QString> mainInputWidget::returnTravelTableData()
{
QMultiMap<int, QString> rowStrings;
for (int row = 0; row < ui.MItravelTreeWidget->topLevelItemCount(); ++row)
{
for (int column = ui.MItravelTreeWidget->columnCount() - 1; column >= 0; --column)
{
qDebug() << "column" << column;
qDebug() << "row" << row;
rowStrings.insert(row, ui.MItravelTreeWidget->itemAt(row,column)->text(column));
}
}
return rowStrings;
}
To copy to clipboard, switch view to plain text mode
The loops are working right according the qDebugged row and column values, but the problem is with
ui.MItravelTreeWidget->itemAt(row, column)
ui.MItravelTreeWidget->itemAt(row, column)
To copy to clipboard, switch view to plain text mode
It keeps pointing to the first row.
Probably I'm not using this function correctly. What should I do different or is there another solutions that works as well?
Thanks for answering.
Bookmarks