Dispaly three items of QStringList in one QtableWidget element

377 Views Asked by At

I have a binary vector (it is in hex)

For Example -

x={0x06, 0xfc, 0x47}

I want to save it in a QStringList and then read it from the list and display all of them in one element of QTableWidget. How can I do this? I did this previously with a for loop but it only displays the last vector element (0x47) in the table.

Thanks.

1

There are 1 best solutions below

4
On BEST ANSWER

You can do it like this:

 QStringList list;
 for(int i = 0; i < vector.size(); ++i)
 {
     list.append(QString::number(vector[i], 16));
 }
 // i - row, j - column in function join put your separator(for example "\n" if you want all items in new row)
 ui->tableWidget->setItem(i,j, new QTableWidgetItem(list.join("\n"));