I want to write a data to a file. I am formatting that Data using C++'s iomanip function, setw to set width of Text Field. Source code is as below:
std::ofstream dataFile;
dataFile.open(m_fileAbsolutePath.toStdString().c_str(),std::fstream::out);
dataFile << "|";
SET_WIDTH(dataFile,DEV_NAME_FIELD);
dataFile << std::right <<TS_HEADER;
The formatting looks good in Linux Text Editor "gedit". But, when I try to read this file and show in QT's QTextEdit, the formatting becomes Mess.
The width that was set using "C++'s setw" function, does not show up properly. Why is it so ? Do we need to do some configuration for QTextEdit ?
TextEdit is set as:
ui->textEdit->setLineWrapMode(QTextEdit::NoWrap);
Code to read file:
std::ifstream dataFile (m_filePath.toStdString().c_str(), std::ifstream::in);
if(dataFile.is_open()){
while (!dataFile.eof()) {
char line[1024] = {0};
dataFile.getline(line,1024);
int numberOfBytes = dataFile.gcount();
if(0 < numberOfBytes){
QString result(line);
Q_EMIT resultReady(result);
}
}
dataFile.close();
}
Thanks in advance.