void MainWindow::updateTable(QVariantMap values){ qDebug() << values["data1"]; int f = 17; ui->tableWidget->setRowCount(17); for (int i = 0; i < 17; i++) { QTableWidgetItem *item = new QTableWidgetItem; item->setData(Qt::UserRole, values["data1"]); ui->tableWidget->setItem(i, 2, item); }}
item->setData(Qt::UserRole, values["data1"].toString());
item->setText(values["data1"].toString());
C++ (Qt)...QMapIterator<QString, QVariant> i(values);while (i.hasNext()) { i.next(); qDebug() << i.key() << ": " << i.value();}...
QVariantList data1; QVariantList data2;... QVariantMap result; result["data1"] = data1; result["data2"] = data2; return result;
QVariantList sens_temp; QVariantList sens_humm; for (const Sensors & Sensor : response.dataPack.sensor) { sens_temp.push_back(Sensor.temperature); sens_humm.push_back(Sensor.humidity); } QVariantMap result; result["sens_temp"] = sens_temp; result["sens_humm"] = sens_humm; return result;
void MainWindow::updateTable(QVariantMap values){ qDebug() << values["sens_temp"];// тут должен быть вывод в таблицу}
foreach (QVariant s, values["sens_temp"].toList()) { QTableWidgetItem *item = new QTableWidgetItem; item->setData(Qt::DisplayRole, s.toString()); ui->tableWidget->setItem(i++, 2, item); }
void MainWindow::updateTable(QVariantMap values){ int i = 0; foreach (QVariant s, values["sens_temp"].toList()) { ui->tableWidget->setRowCount(sizeof(s)); QTableWidgetItem *item = new QTableWidgetItem; item->setData(Qt::DisplayRole, s.toString()); ui->tableWidget->setItem(i++, 2, item); } int j = 0; foreach (QVariant s, values["sens_humm"].toList()) { ui->tableWidget->setRowCount(sizeof(s)); QTableWidgetItem *item = new QTableWidgetItem; item->setData(Qt::DisplayRole, s.toString()); ui->tableWidget->setItem(j++, 3, item); }}
QMap(("sens_humm", QVariant(QVariantList, (QVariant(int, 19) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 1) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) ) ) ) ( "sens_temp" , QVariant(QVariantList, (QVariant(int, 25) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) , QVariant(int, 240) ) ) ) )