PDA

View Full Version : QString argument ignoring new line characters



qtnewbi3
15th August 2011, 15:28
Hi,

I am using a QStringList with a few strings and passing the required string as an argument. I am also changing the parameters of the string in css i.e using pstyle and font color size etc. when I pass a string with new line characters the Qstring is displayed in one line instead of multiple lines, however if i put a <br> in the string then it ignores all the css parameters and just puts a break. Can anyone point me in the right direction.

Thanks

wysota
15th August 2011, 18:48
It would be nice if you said what you were talking about.

qtnewbi3
15th August 2011, 18:54
Hi wyotsa,

Sorry anyway here is the setup i had:


Labels.at(i)->setText(QString("<p style=\" font-family: SansSerif; font-size: 10pt;margin-left: 20px; \">%1</p>").arg(Names.at(i)));

I was trying to put new line characters into the argument "Names" but they were ignored. I figured out that a <br /> works once I looked at the Rich text documentation , please let me know if there is a better solution.

Thanks

wysota
15th August 2011, 19:06
Linebreaks will be ignored when using rich text. <br/> is the way to go. However the best solution would be to use multiple labels or a list view.

qtnewbi3
15th August 2011, 23:18
Cool, oh this was just a way to have the text on the label so that its visible on multiple lines based on the length of text.