PDA

View Full Version : doubt in QLabel



iswaryasenthilkumar
13th July 2015, 11:19
i need to display the below text in QLabel
"The text will be plain text. Setting the text clears any previous content."


label->setText(" The text will be plain text. Setting the text clears any previous content.");
label4->setWordWrap(true);

i getting the output in label


The text will be plain text. Setting the text clears
any previous content.

but i need the output


The text will be plain text.
Setting the text clears any previous content.

i need this output in twoline.please guide me to get proper result

anbu01
13th July 2015, 11:40
use \n (escape sequence) wherever you require.In your example

label->setText(" The text will be plain text.\n Setting the text clears any previous content.");
label->setWordWrap(true);

Radek
13th July 2015, 11:58
label->setText(QString("The text will be plain text.") + QString(QChar::LineFeed) + QString("Setting the text clears any previous content."));

iswaryasenthilkumar
13th July 2015, 12:14
i got error when i use Linefeed,instead of the i used lineseparator its work and fine



label->setText(QString("The text will be plain text.") + QString(QChar::LineFeed) + QString("Setting the text clears any previous content."));

anbu01
13th July 2015, 14:05
@ishwarya
can you say what error you get on using lineFeed(suggested by Radek) because it works fine for me.