Jonathan Maen
28th January 2012, 11:23
Hello guys,
I've been having problems exporting source to a QTextStream using a QStringList.
This is my code trying to export;
Something
Something Two
And i've got;
S O M E T H I N G .... etc...
This is my code;
for (int j = 0; j < TalkList[i].Script_t.size(); j++)
{
luaTxt << QString("\t\t%1").arg(TalkList[i].Script_t.at(j).toLocal8Bit().constData());
//luaTxt << TalkList[i].Script_t.value();
}
Script_t is a QStringList
I'm trying to parse the lines one by one to the textstream with 2 initial tabs (\t\t) but result is strange.
Please help me it's 6:53 and I've 2 hours trying to solve it :(
wysota
28th January 2012, 12:37
What is the type of TalkList.Script_t?
Jonathan Maen
28th January 2012, 20:43
I've said in the post it; Script_t is a QStringList
wysota
28th January 2012, 20:47
What happens if you do this?
luaTxt << QString("\t\t%1").arg(TalkList[i].Script_t.at(j));
Jonathan Maen
28th January 2012, 20:49
I get the same, each characterin the file is separated with the 2 tabs which shouldn't be happening.
I'm trying to add all of the lines with 2 tabs in the very beginning, but seems i've been not allowed to do this.
wysota
28th January 2012, 21:43
ok, what does this print?
qDebug() << TalkList[i].Script_t;
Jonathan Maen
28th January 2012, 21:54
ok, what does this print?
qDebug() << TalkList[i].Script_t;
("l", "o", "c", "a", "l", " ", "m", "y", "V", "a", "r", " ", "=", " ", "1", "0", "0", "0", "
", "n", "p", "c", "H", "a", "n", "d", "l", "e", "r", ":", "s", "a", "y", "(", "m", "y", "V", "a", "r", ",", " ", "c", "i", "d", ")", "
", "n", "p", "c", "H", "a", "n", "d", "l", "e", "r", ":", "r", "e", "l", "e", "a", "s", "e", "F", "o", "c", "u", "s", "(", "c", "i", "d", ")")
wysota
28th January 2012, 22:08
Apparently your stringlist is incorrect. How did you create it?
Jonathan Maen
28th January 2012, 22:27
item.Script_t = ui->textEdit->toPlainText();
I've tried at(i) and still same results.
wysota
29th January 2012, 00:41
toPlainText() returns QString and not QStringList. So is it QString or QStringList? Is the code you posted your actual code or "sort of" your code?
wysota
31st January 2012, 03:01
So is it QString or QStringList? If it's QStringList then the code shouldn't compile.
Jonathan Maen
1st February 2012, 06:40
Script_t is QStringList and it compiles on my VS2010.
MrShahi
1st February 2012, 07:04
Wysota is right , toPlainText() returns QString and not QStringList. So access your each value ,split that string into a stringlist..
wysota
1st February 2012, 08:12
Script_t is QStringList and it compiles on my VS2010.
Please check that as the application behaves as if it were not a string list.
Jonathan Maen
1st February 2012, 22:37
So It's been a few days since I've got this problem, and since I'm just 17 years old, and just 2 weeks with C++ and Qt, I'm just learning.
What's the best way to parse each line of QTextEdit into a QStringList, I really need this in order to add 2 tabs to the beginning of every line of the file.
wysota
1st February 2012, 22:55
The most basic approach I can think of is:
QStringList lines = textEdit->toPlainText().split("\n");
However that's probably not the best possible way. It would be much better (albeit more complicated) to use QTextDocument API.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.