[Qt-interest] [Qt interest] QByteArray conversion

Gerardo Gutierrez muzgash at gmail.com
Sat Jan 23 00:56:34 CET 2010


This piece of code intends to read a file with "double" data to plot, it
doesn't matter wich index i put in signal to write on stdout it's zero, and
obviously the plot is a nice line at zero.


PaintArea::PaintArea(QString ffile)
{
        fileSize=0;
int i=0;
        QFile file(ffile);
        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
                return;

        while (!file.atEnd()) {
                QByteArray line = file.readLine();
                fileSize++;
        }
signal=(double*)malloc(fileSize*sizeof(double));
while (!file.atEnd()) {
                QByteArray line = file.readLine();
                signal[i]=line.toDouble();
i++;
        }
 cout<<signal[35]<<endl;
}


-- 
"Solo existen 10 tipos de personas en el mundo...
las que saben binario y las que no"

   _-`````-,           ,- '- .
 .'   .- - |          | - -.  `.
/.'  /                     `.   \
:/   :      _...   ..._      ``   :
::   :     /._ .`:'_.._\.    ||   :
::    `._ ./  ,`  :    \ . _.''   .
`:.      /   |  -.  \-. \\_      /
 \:._ _/  .'   .@)  \@) ` `\ ,.'
    _/,--'       .- .\,-.`--`.
      ,'/''     (( \ `  )
       /'/'  \    `-'  (
        '/''  `._,-----'
         ''/'    .,---'
          ''/'      ;:
            ''/''  ''/
              ''/''/''
                '/'/'
                 `;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100122/ca354c10/attachment.html 


More information about the Qt-interest-old mailing list