Hi I am writting an array of type double into a binary file use QDataStream. This works well with following code
Now i wan to read the same file but I am unable to do that i tried following coesQFile file("sine.bin");
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
int i = 0;
while( i < 100 )
{
for( double x = 0; x < 2.0 * 3.141 * 5; x += ( 3.141 / 10.0 ) )
{
yl[i] = sin(x);
qDebug()<<" y1 =="<<yl[i];
out <<yl[i];
xl[i] = x;
qDebug()<<" X1 =="<<xl[i];
out <<xl[i];
i++;
}
}
Any help will be great for meQt Code:
{ // data.setByteOrder(data.LittleEndian); double intb; data>>intb; qDebug()<<intb; }To copy to clipboard, switch view to plain text mode
Added after 1 9 minutes:
I solved it
here is the code
QString fileName = QFileDialog::getOpenFileName(this);
QFile fileToRead(fileName);
fileToRead.open(QIODevice::ReadOnly);
{
QDataStream data (&fileToRead);
// data.setByteOrder(data.LittleEndian);
while( !data.atEnd() ) {
double intb;
data>>intb;
qDebug()<<intb;
}
}
Bookmarks