How do I convert QTableWidget::item to double?
Code:
void Method::setMatrix() { for (int i = 0; i < rowCount; ++i) { for (int j = 0; j < columnCount; ++j) { a[i][j] = table->item(i, j); } } }
Printable View
How do I convert QTableWidget::item to double?
Code:
void Method::setMatrix() { for (int i = 0; i < rowCount; ++i) { for (int j = 0; j < columnCount; ++j) { a[i][j] = table->item(i, j); } } }
Like this
You can even set the data to the table widget as doubles instead of text. Then you'd have double spin boxes in editing mode (editors will be line edits if you set the data as text) and you'll avoid explicitly converting the string to a double again and again (instead you'll get directly the double contained by the variant):
Code:
// set double num = ... item->setData(Qt::DisplayRole, num); // get double result = item->data(Qt::DisplayRole).toDouble();