Unsolved ıt doesnt add list items into table widget
-
I know, my list is not empy, but it didnt add list items into table
void MainWindow::tablo_olustur() { ui->tableWidget->setRowCount(gpsList.size()); for ( int row = 0; row < gpsList.size(); ++row ) { for (int i=0; i<gpsList.size() ; i++ ) { ui->tableWidget->setItem(row, 0, new QTableWidgetItem(gpsList[i])); } } qDebug() << gpsList; }
-
@suslucoder So, what did you try so far to find out what happens? You do not even have debug output (only one)! Please first try to find the issue by yourself. And why do you add up to i items in same row and same column? You will only see the last one...
for (int i=0; i<gpsList.size() ; i++ ) { ui->tableWidget->setItem(row, 0, new QTableWidgetItem(gpsList[i])); // You put all 0..i gpsList elements in exactly same cell! }
-
@jsulm ı tried to do
```
ui->tableWidget->setItem(0, 0, new QTableWidgetItem(gpsList[i0]));
but it doesnt work still :(
-
Hi,
Why do you have a double loop in the first place ?
-
@suslucoder Can you please explain how you want to put the elements from gpsList into your table? All elements in one row or something else? As @SGaist pointed out iterating over the same list in two nested loops does not make sense...