Hi,
I want to edit the example Scatterplot that comes with Qwt in such a way that i can read data(x and y coordinates) from an external txt file and plot it like the example. I am new in Qt/Qwt/C++, but I learned C# at school.
I know I need QTextStream to read the data but I dont now how to save it in 2 arrays(x and y) and the next problem is I dont now what I need/I can delete from the source code of the example. I'm sorry for my bad english but I need your help D:

mainwindow.cpp:

#include "mainwindow.h"
#include "plot.h"
#include <qmath.h>

static double randomValue()
{
// a number between [ 0.0, 1.0 ]
return ( qrand() % 100000 ) / 100000.0;
}

MainWindow::MainWindow()
{
d_plot = new Plot( this );
d_plot->setTitle( "Scatter Plot" );
setCentralWidget( d_plot );

// a million points
setSamples( 100000 );
}

void MainWindow::setSamples( int numPoints )
{
QPolygonF samples;

for ( int i = 0; i < numPoints; i++ )
{
const double x = randomValue() * 24.0 + 1.0;
const double y = ::log( 10.0 * ( x - 1.0 ) + 1.0 )
* ( randomValue() * 0.5 + 0.9 );

samples += QPointF( x, y );
}

d_plot->setSamples( samples );
}


plot.cpp:

#include "plot.h"
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <qwt_plot_curve.h>

class DistancePicker: public QwtPlotPicker
{
public:
DistancePicker( QWidget *canvas ):
QwtPlotPicker( canvas )
{
setTrackerMode( QwtPicker::ActiveOnly );
setStateMachine( new QwtPickerDragLineMachine() );
setRubberBand( QwtPlotPicker::PolygonRubberBand );
}

virtual QwtText trackerTextF( const QPointF &pos ) const
{
QwtText text;

const QPolygon points = selection();
if ( !points.isEmpty() )
{
QString num;
num.setNum( QLineF( pos, invTransform( points[0] ) ).length() );

QColor bg( Qt::white );
bg.setAlpha( 200 );

text.setBackgroundBrush( QBrush( bg ) );
text.setText( num );
}
return text;
}
};

Plot::Plot( QWidget *parent ):
QwtPlot( parent ),
d_curve( NULL )
{
canvas()->setStyleSheet(
"border: 2px solid Black;"
"border-radius: 15px;"
"background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );"
);

// attach curve
d_curve = new QwtPlotCurve( "Scattered Points" );
d_curve->setPen( QColor( "Purple" ) );

// when using QwtPlotCurve::ImageBuffer simple dots can be
// rendered in parallel on multicore systems.
d_curve->setRenderThreadCount( 0 ); // 0: use QThread::idealThreadCount()

d_curve->attach( this );

setSymbol( NULL );

// panning with the left mouse button
(void )new QwtPlotPanner( canvas() );

// zoom in/out with the wheel
QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
magnifier->setMouseButton( Qt::NoButton );

// distanve measurement with the right mouse button
DistancePicker *picker = new DistancePicker( canvas() );
picker->setMousePattern( QwtPlotPicker::MouseSelect1, Qt::RightButton );
picker->setRubberBandPen( QPen( Qt::blue ) );
}

void Plot::setSymbol( QwtSymbol *symbol )
{
d_curve->setSymbol( symbol );

if ( symbol == NULL )
{
d_curve->setStyle( QwtPlotCurve::Dots );
}
}

void Plot::setSamples( const QVector<QPointF> &samples )
{
d_curve->setPaintAttribute(
QwtPlotCurve::ImageBuffer, samples.size() > 1000 );

d_curve->setSamples( samples );
}