I have written a piece of code that should save doubles in an csv file. Here it is:
QString fileName = QFileDialog::getSaveFileName(this,tr("Save Logger Data"), "",tr("LoggerData(*.csv);;All Files (*)"));
if (fileName.isEmpty())
{
return;
}
else
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
return;
}
QDataStream out(&file);
out << data1 << "/t" << data2 << "/n";
}
Here, data1 and data2 are doubles. When I open the savefile I only see weird characters (I asume they are hexadecimal values??). How can I change my code so it saves doubles instead of hex?
QDataStream is not the right class for this. For text output use QTextStream instead.