踩坑记录:
通过setCellWidget插入的如QSpinBox、QCheckBox,后续访问也要通过tableWidget->cellWidget(row, column)来访问,无法通过item()访问
QSpinBox* spin_test = new QSpinBox;
spin_test->setRange(0,2000);
spin_test->setValue(1000);
spin_test->setSingleStep(1);
spin_test->setSuffix(" Hz"); // 后缀
spin_test->setWrapping(true); // 开启循环
QSpinBox* spin_test1 = new QSpinBox;
spin_test1->setRange(0,50000);
spin_test1->setValue(1000);
spin_test1->setSingleStep(1);
spin_test1->setSuffix(" Hz"); // 后缀
spin_test1->setWrapping(true); // 开启循环
ui->tableWidget->insertRow(0);
ui->tableWidget->setItem(0, 0, new QTableWidgetItem("test"));
ui->tableWidget->setCellWidget(0, 1, spin_test);
ui->tableWidget->setCellWidget(0, 2, spin_test1);
cout << "cellwidget value is :" << static_cast<QSpinBox*>(ui->tableWidget->cellWidget(0, 1))->value() << endl;