Aleph0
Aleph0

Reputation: 6074

QTableWidget having multiples lines in cell

I'm using a QTableWidget for a simple table. Now each cell should contain two numbers, but I don't want them to be left to right, but for readability on top of each other. I'm using Qt 5.8.

Hence, I tried something like this:

QTableWidget* table=new QTableWidget;
auto item = new QTableWidgetItem(QString("%1\n%2").arg(1).arg(2));
table->setItem(0, 0, item);

Interestingly, the outcome was that the newline \n was completely ignored. I obtain a cell containing 12. Replacing \n by <br> didn't helped.

Any idea, what I'm doing wrong/missing?

Upvotes: 0

Views: 894

Answers (1)

rTz
rTz

Reputation: 21

This should work, just try to resize the height of your row to give the item enough space.

Upvotes: 2

Related Questions