Reputation: 2695
There is QListWidget
. If I add an item with the text like "Line1\nLine2" I get an item containing a one string.
How can I make this item containing two strings?
Upvotes: 2
Views: 2582
Reputation: 243897
It seems that the editor adds one more backslash as the following image shows:
The solution is simple, you must edit the text in Object Inspector and add it there directly as I show below:
Upvotes: 1
Reputation: 4582
You could add two lines to QListWidget
in two way:
First:
listWidget->addItem(tr("Line1\nLine2"));
or
new QListWidgetItem(tr("Line4\nLine5"), listWidget);
and that should work as per common testing.
Second, and the better way is to add multiple items using addItems()
with QStringList
QStringList items;
items << "Line1";
items << "Line2";
listWidget->addItems(items);
Upvotes: 1