thanks a lot
i have tried it but having some errors
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QString>
#include <qwt_plot.h>
MainWindow
::MainWindow( QWidget* p
): plot
( new QwtPlot( this ) ),
// create plot widget x( QVector< double >() ),
y( QVector< double >() )
{
QToolBar* tb
= this
->addToolBar
( "File" );
tb->addAction( "Open File", this, SLOT( openFile() ) );
this->setCentralWidget( this->plot );
}
void MainWindow::openFile( void )
{
if( !str.isEmpty() )
{
if( !curve )
{
return;
}
curve->attach( this->plot );
this->plot->replot();
}
}
{
int size = 0;
{
return NULL;
}
while( !src.atEnd() )
{
// x is placeholder if you don't have anything better
this->x.append( size ); // this->y is QVector< double > which need to be kept alive as long as curve uses the data!
this->y.append( src.readLine().toDouble() ); // this->x is QVector< double > which need to be kept alive as long as curve uses the data!
++size;
}
c->setSamples( this->x.at( idx ).data(), this->y.at( idx ).data(), size );
return c;
}
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QString>
#include <qwt_plot.h>
MainWindow::MainWindow( QWidget* p ):
QMainWindow( p ),
plot( new QwtPlot( this ) ), // create plot widget
x( QVector< double >() ),
y( QVector< double >() )
{
QToolBar* tb = this->addToolBar( "File" );
tb->addAction( "Open File", this, SLOT( openFile() ) );
this->setCentralWidget( this->plot );
}
void MainWindow::openFile( void )
{
QString str = QFileDialog::getOpenFileName( this );
if( !str.isEmpty() )
{
QwtPlotCurve* curve = this->getCurve( str );
if( !curve )
{
return;
}
curve->attach( this->plot );
this->plot->replot();
}
}
QwtPlotCurve* MainWindow::getCurve( const QString& path )
{
int size = 0;
QFile src( path );
if( !src.open( QIODevice::ReadOnly ) )
{
return NULL;
}
while( !src.atEnd() )
{
// x is placeholder if you don't have anything better
this->x.append( size ); // this->y is QVector< double > which need to be kept alive as long as curve uses the data!
this->y.append( src.readLine().toDouble() ); // this->x is QVector< double > which need to be kept alive as long as curve uses the data!
++size;
}
QwtPlotCurve* c = new QwtPlotCurve();
c->setSamples( this->x.at( idx ).data(), this->y.at( idx ).data(), size );
return c;
}
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
1st problem is i QWT library not installed and i have read lot of threads but unfortunately i cant install it
2nd problem is i am a beginner and i feel there is some thing wrong in my above code
can i get help to fix these errors?
thanks in advance
Bookmarks