Load QTableWidgetItem from file
-
I have saved ui->tableWidgetName->verticalHeader() to a text file. In the file it appears like this: 0x1ef54c8.
I load the hex from the file to a QString (var) but do not know how to convert it to a QTableWidgetItem for setting the header on the table when the program is re-opened. -
Hi,
Writing and loading from files (or any other QIODevice) should be done the same way. So writing with the QString << operator will result in a QString >> operator reading.
When you have the QString, simply set the text of the QTableWidgetItem with
@
ui->tableWidgetName->VerticalHeaderItem(<<your column>>)->setText(<<your string>>);
@ -
That would work for setting a single header; but I am trying to set them all at once using the entire verticalHeader, i.e., the name of row1, name of row2, name of row3.... If I must make a for loop and do it in the method you stated I shall; will do so now as a temporary solution; but would prefer to use functions already available if they exist.