Hello everyone, I'm making a small program that will ease the process of opening files at the law firm I work for. Anyways, I'm having a difficult time with the append class of QTString.
I am trying to write to a csv file through user input, but need to get past this step first. (everything but 1 will be through user input, and date will take the system date)
The specific format it needs to look like is:
,"defendant",advs.,"plaintiff",Lawyer,1,date,,, ,,,
The function:
void csvWriting()
{
QFile file("register.csv");
string.append(defendant + camma + advs + camma + plaintiff + camma + lawyer + camma + date + ending);
out << string;
file.close();
}
void csvWriting()
{
QFile file("register.csv");
file.open(QIODevice::Append | QIODevice::Text);
QDataStream out(&file);
QString string = " ,";
QString defendant = "Defendant";
QString camma = ",";
QString advs = "advs.";
QString plaintiff = "Plaintiff";
QString lawyer = "lawyer";
QString date = "date";
QString ending = ", , , , , \n";
string.append(defendant + camma + advs + camma + plaintiff + camma + lawyer + camma + date + ending);
out << string;
file.close();
}
To copy to clipboard, switch view to plain text mode
However, when it outputs, a random character (seems to like b/d) is inserted into the string:
d , D e f e n d a n t , a d v s . , P l a i n t i f f , l a w y e r , d a t e , , , , ,
I'm assuming it has something to do with the appending process as when I was doing the test writing with a single string this did not happen. Does a "," have an escape character I could use instead? The subsequent "," that are appending don't produce this outcome though...
Where is this d coming from, and how would I fix it? As a side note, I am not sure why all the letters have spaces between them, but, for my purposes, it doesn't seem to matter.
(perhaps it would just be easier to do "out << string; out << camma;" etc.)
Bookmarks