PDA

View Full Version : A list of qstring



maider
25th November 2009, 08:12
Hey,

I'm trying to do a list of strings. I have added the strings like this:

QList <QString> list;
list.insert(0,"text0");
list.insert(1,"text1");
list.insert(2,"text2");
list.insert(3,"text3");
list.insert(4,"text4");
list.insert(5,"text5");
list.insert(6,"text6");
list.insert(7,"text7");
list.insert(8,"text8");
list.insert(9,"text9");

Now in depends on what number I introduce, i have to see in a text Edit, one text of the string of another.
to get this i have done the following one,but it doesn't work:

ui.textEdit->show(list.at[0]);

do you know why?

caduel
25th November 2009, 08:33
Try calling QTextEdit::setPlainText() instead of show().
(Who/what suggested you to use show()? Show() does not take an argument and just tells the (any) widget to become visible. See the docs of QWidget and QTextEdit for details.)

nish
25th November 2009, 10:19
and better use QStringList instead of QList<QString>

Lykurg
25th November 2009, 13:05
and better use QStringList instead of QList<QString>
...only if you really need some functions provided by QStringList (and not by QList itself). If not there is no need for that since QStringList inherits QList<QString>...