[SOLVED]textBrowser->setText or textEdit->setText Using String Array
-
wrote on 2 Dec 2012, 13:07 last edited by
This Forum seems to be pretty vivid,
so I hope you can help me with this little problem.I do have an array:
@QString key_storage[20]@
filled with some values.
I want them all to be displayed in a textBrowser or textEdit field.
@ while (j <=i)
{
ui.textBrowser->setText( key_storage[j] );j++;}@
if I do like this, it works but the next array is replaced with the before one.
so I can always just show one line.
But I want them all.How can i do this?
I am looking for something like a textBrowser->addText command
-
wrote on 2 Dec 2012, 13:11 last edited by
Use QTextEdit::append or build a QString from all strings and then call setText once.
And once again: Don't use C-Arrays here. You're shooting yourself in the foot. Use QStringList. It could be that easy:
@
QStringList strings;
strings << "line one" << "line two";
yourTextEdit->setText(strings.join("\n"));
@ -
wrote on 2 Dec 2012, 13:26 last edited by
hi, thanks for your quick respond,
I am gonna try it right away.
okay I will try avoid C-Arrays,
but thats what I learned the last 2 semesters,
its hard just to forget it, what those proferssors tried to burn into your mind. -__-thank you once again
-
wrote on 2 Dec 2012, 13:37 last edited by
great, that was exactly what I was looking for
@ QStringList strings;
for (int b = 0; b<=20; b++){
strings << key_storage[b]; }
ui.textEdit->setText(strings.join("\n"));@gonna mark is as solved
1/4