Reputation: 3131
I am having trouble to put new line in QTableWidgetItem. Here is the code :
QTableWidget* item = new QTableWidgetItem;
item->setText("Line1 \n Line2");
With this code the item text is not displayed in two lines, i.e it seems that \n character is ignored.
I have a workaround to do this, with using QPlainTextEdit and the function setCellWidget, in that case everything work as expected but is more ugly, and I prefer not to make additional widget just to show text in multiple lines.
Upvotes: 2
Views: 4076
Reputation: 449
I think your code is fine to separate lines. But you should change the size of each row to show multi-lines.
And after resizing row's height:
You see it's OK.
Upvotes: 4