Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: How Can i Load data from file.ecg and plot it ?

  1. #1
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Question How Can i Load data from file.ecg and plot it ?

    hello every body, i am a student in engineering, graduation stage.
    i want to read data from file has an extension of .ecg or any extension and plot these data.
    how can i do this ?
    i am using qt 4.7.4 version
    plz help me as i am really need this program.
    thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    You seem to be expecting some QReadAndInterpretECGorAnyFile class for an unspecified meaning of "ECG" or "any" file... it isn't going to happen.

    The general proces implied by your general requirement is; open the file (QFile), read and interpret the file content (QFile, QIODevice, and/or QTextStream), and do something with the resulting data.

    Qwt offers reasonable plotting facilities and also has a sub-forum here.

  3. #3
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    thanks a lot for your help
    but when i use this code i have some errors
    i am using GUI application
    can you help me to fix this?. sorry for annoying you but i am a beginner ... thanks in advance

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include<QFile>
    4. #include<QtCore>
    5. #include<QtGui>
    6. #include<QTextStream>
    7.  
    8. MainWindow::MainWindow(QWidget *parent) :
    9. QMainWindow(parent),
    10. ui(new Ui::MainWindow)
    11. {
    12. ui->setupUi(this);
    13. ui->label->setText("Hello User :)");
    14.  
    15. }
    16.  
    17. MainWindow::~MainWindow()
    18. {
    19. delete ui;
    20. }
    21.  
    22. void MainWindow::on_pushButton_clicked()
    23. {
    24. QFile file("C:/ahmad/ecg test/tst.txt");
    25. if(!file.open( QFile::ReadOnly | QFile::Text))
    26. {
    27. ui->label->setText(" OOP : File Cant be Opened");
    28. return;
    29. }
    30. QTextStream in(&file);
    31. ui->label->setText("DONE : file opened");
    32. while (!in.atEnd())
    33. {
    34. list << in.readLine();
    35. }
    36. file.close();
    37. data = new double[list.size()];
    38. for(int i = 0; i< list.size(); i++)
    39. {
    40. data[i] = list[i].toDouble();
    41. }
    42. dataSize = list.size();
    43. }
    To copy to clipboard, switch view to plain text mode 


    and the errors are:
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:38: error: C2248: 'QWidget::data' : cannot access private member declared in class 'QWidget'
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:38: error: C2440: '=' : cannot convert from 'double *' to 'QWidgetData *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:41: error: C2248: 'QWidget::data' : cannot access private member declared in class 'QWidget'
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:41: error: C2679: binary '=' : no operator found which takes a right-hand operand of type 'double' (or there is no acceptable conversion)
    C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\include\QtGui/qwidget.h(143): could be 'QWidgetData &QWidgetData::operator =(const QWidgetData &)'
    while trying to match the argument list '(QWidgetData, double)'
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:43: error: C2065: 'dataSize' : undeclared identifier
    Last edited by wysota; 20th March 2012 at 08:20. Reason: missing [code] tags

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    Where is the variable data declared? It appears that it is not declared, and coincidentally there is an existing member data of incompatible type inherited from QWidget, which is what the error message is telling you.

    Rather than using a bare array (i.e. data) you should consider using QList or QVector which will manage the memory for you. You could also consider going straight from the line read from file to a QList<double> without the intervening QStringList.

  5. The following user says thank you to ChrisW67 for this useful post:

    ahmed ali (20th March 2012)

  6. #5
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    thanks a lot ChrisW67,
    I tried to use this code:
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include<QFile>
    4. #include<QtCore>
    5. #include<QtGui>
    6. #include<QList>
    7. #include<QTextStream>
    8.  
    9. MainWindow::MainWindow(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::MainWindow)
    12. {
    13. ui->setupUi(this);
    14. ui->label->setText("Hello User :)");
    15.  
    16. }
    17.  
    18. MainWindow::~MainWindow()
    19. {
    20. delete ui;
    21. }
    22.  
    23. void MainWindow::on_pushButton_clicked()
    24. {
    25. QFile file("C:/ahmad/ecg test/tst.txt");
    26. if(!file.open( QFile::ReadOnly | QFile::Text))
    27. {
    28. ui->label->setText(" OOP : File Cant be Opened");
    29. return;
    30. }
    31. QList<double> list;
    32. QTextStream in(&file);
    33. ui->label->setText("DONE : file opened");
    34. while (!in.atEnd())
    35. {
    36. list << in.readLine();
    37. }
    38. file.close();
    To copy to clipboard, switch view to plain text mode 

    but unfortunately have some error too
    C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:36: error: C2678: binary '<<' : no operator found which takes a left-hand operand of type 'QList<T>' (or there is no acceptable conversion)

    and if i have loaded the data to Qlist<double> list , how can i then plot these data ?
    Last edited by wysota; 20th March 2012 at 08:21. Reason: missing [code] tags

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    You are trying to append a QString to a list of doubles. Perhaps you need to convert to double like you were before. Is there only one number on each line?

  8. The following user says thank you to ChrisW67 for this useful post:

    ahmed ali (20th March 2012)

  9. #7
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    yes, every line has one value
    (i.e 1.8600000e+03
    1.8640000e+03
    1.8660000e+03
    1.8550000e+03
    1.8660000e+03
    1.8760000e+03

  10. #8
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How Can i Load data from file.ecg and plot it ?

    Hmmm you need at least two coordinates to plot anything.
    The values you have are probably Y values where time increases in constant.

    try this:
    Qt Code:
    1. MainWindow::MainWindow( QWidget* p )
    2. :
    3. plot( new QwtPlot( this ) ), // create plot widget
    4. x( QVector< double >() ),
    5. y( QVector< double >() )
    6. {
    7. QToolBar* tb = this->addToolBar( "File" );
    8. tb->addAction( "Open File", this, SLOT( openFile() ) );
    9. this->setCentralWidget( this->plot );
    10. }
    11.  
    12. void MainWindow::openFile( void )
    13. {
    14. QString str = QFileDialog::getOpenFileName( this );
    15. if( !str.isEmpty() )
    16. {
    17. QwtPlotCurve* curve = this->getCurve( str );
    18.  
    19. if( !curve )
    20. {
    21. return;
    22. }
    23.  
    24. curve->attach( this->plot );
    25. this->plot->replot();
    26. }
    27. }
    28.  
    29. QwtPlotCurve* MainWindow::getCurve( const QString& path )
    30. {
    31. int size = 0;
    32.  
    33. QFile src( path );
    34. if( !src.open( QIODevice::ReadOnly ) )
    35. {
    36. return NULL;
    37. }
    38.  
    39. while( !src.atEnd() )
    40. {
    41. // x is placeholder if you don't have anything better
    42. this->x.append( size ); // this->y is QVector< double > which need to be kept alive as long as curve uses the data!
    43. this->y.append( src.readLine().toDouble() ); // this->x is QVector< double > which need to be kept alive as long as curve uses the data!
    44. ++size;
    45. }
    46.  
    47. c->setSamples( this->x.at( idx ).data(), this->y.at( idx ).data(), size );
    48. return c;
    49. }
    To copy to clipboard, switch view to plain text mode 
    It's all you need to load a file and plot it.

  11. The following user says thank you to Spitfire for this useful post:

    ahmed ali (20th March 2012)

  12. #9
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    thanks a lot i will try it now and i will reply

  13. #10
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    thanks a lot
    i have tried it but having some errors
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include<QString>
    4.  
    5. #include <qwt_plot.h>
    6.  
    7.  
    8. MainWindow::MainWindow( QWidget* p ):
    9. plot( new QwtPlot( this ) ), // create plot widget
    10. x( QVector< double >() ),
    11. y( QVector< double >() )
    12. {
    13. QToolBar* tb = this->addToolBar( "File" );
    14. tb->addAction( "Open File", this, SLOT( openFile() ) );
    15. this->setCentralWidget( this->plot );
    16. }
    17.  
    18. void MainWindow::openFile( void )
    19. {
    20. QString str = QFileDialog::getOpenFileName( this );
    21. if( !str.isEmpty() )
    22. {
    23. QwtPlotCurve* curve = this->getCurve( str );
    24.  
    25. if( !curve )
    26. {
    27. return;
    28. }
    29.  
    30. curve->attach( this->plot );
    31. this->plot->replot();
    32. }
    33. }
    34.  
    35. QwtPlotCurve* MainWindow::getCurve( const QString& path )
    36. {
    37. int size = 0;
    38.  
    39. QFile src( path );
    40. if( !src.open( QIODevice::ReadOnly ) )
    41. {
    42. return NULL;
    43. }
    44.  
    45. while( !src.atEnd() )
    46. {
    47. // x is placeholder if you don't have anything better
    48. this->x.append( size ); // this->y is QVector< double > which need to be kept alive as long as curve uses the data!
    49. this->y.append( src.readLine().toDouble() ); // this->x is QVector< double > which need to be kept alive as long as curve uses the data!
    50. ++size;
    51. }
    52.  
    53. c->setSamples( this->x.at( idx ).data(), this->y.at( idx ).data(), size );
    54. return c;
    55. }
    56. QMainWindow(parent),
    57. ui(new Ui::MainWindow)
    58. {
    59. ui->setupUi(this);
    60. }
    61.  
    62. MainWindow::~MainWindow()
    63. {
    64. delete ui;
    65. }
    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

  14. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    1st problem is i QWT library not installed and i have read lot of threads but unfortunately i cant install it
    If this is the case then you cannot even compile the code above.

    You do not need forum threads, blogs or Google searches to install Qwt. The instructions are in the INSTALL file that comes with the Qwt source (as Uwe is constantly explaining).

    If you follow the instructions in the INSTALL file, not somewhere else, and strike a problem then post a description of exactly what you did, and what you got that seems broken or wrong. The Qwt sub-forum might be a better place for that.

    2nd problem is i am a beginner and i feel there is some thing wrong in my above code
    Possibly, maybe even probably, but wait until you can build it before you worry about this.

  15. The following user says thank you to ChrisW67 for this useful post:

    ahmed ali (21st March 2012)

  16. #12
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    Thanks a lot, but i am wondering why there is no video tutorial that show us how to install QWT library as i have tried several times but always there are errors
    all i can say now i will try again and thanks for your help

  17. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    There's no video tutorial because the instructions in the INSTALL file are both complete and adequate.

    Since you have not explained the problem you are experiencing actually is we are unable to help.

  18. The following user says thank you to ChrisW67 for this useful post:

    ahmed ali (21st March 2012)

  19. #14
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    thanks a lot,
    I have done these steps to install QWT in my windows:
    1.i downloaded the qwt library called qwt-6.0.1
    2.unzipped it to C:/Qwt
    3.then i started QT command prompt i found it in ( start > QtSDK > Desktop > Qt 4.8.0 for Desktop (MSVC 2010)
    4.cd C:\QWT\qwt-6.0.1 this is the folder where i put the unzipped library
    5.qmake qwt.pro this command executed successfully
    6. when i try to execute nmake or nmake install i have this msg: 'nmake' is not recognized as an internal or external command, operable program or batch file

    i stooped at this point can any body help me ?
    thanks in advance

  20. #15
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How Can i Load data from file.ecg and plot it ?

    Try mingw32-make instead.

  21. #16
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    unfortionatly i have the same error msg
    msg: 'mingw32-make' is not recognized as an internal or external command, operable program or batch file


    Added after 11 minutes:


    thanks to all one tried to help me but can i ask you (ChrisW67) and all experts can you please make a tutorial video to help us to install QWT library? really this will help us greatly, i hope you can do this for us ... this will be great Known to us

    thanks in advance
    Ahmed Ali
    Last edited by ahmed ali; 21st March 2012 at 12:40.

  22. #17
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How Can i Load data from file.ecg and plot it ?

    So, did you managed it in the end?

    On another note - I understand vieo tutorial for cooking or building fusion generator (as a help, not instead of written word), but I totally fail to see a benefit of it for compiling a library or calculating your tax return...
    Maybe it's only me...

  23. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How Can i Load data from file.ecg and plot it ?

    Quote Originally Posted by ahmed ali View Post
    thanks to all one tried to help me but can i ask you (ChrisW67) and all experts can you please make a tutorial video to help us to install QWT library? really this will help us greatly, i hope you can do this for us ... this will be great Known to us
    Sorry to be blunt, but if you don't even know what compiler you are using and how to use it then what good will a video tutorial on installing Qwt do? If you want to act as a programmer then you can't rely on having video tutorials on everything you are trying to do.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  24. The following user says thank you to wysota for this useful post:

    ahmed ali (22nd March 2012)

  25. #19
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How Can i Load data from file.ecg and plot it ?

    Quote Originally Posted by ahmed ali View Post
    6. when i try to execute nmake or nmake install i have this msg: 'nmake' is not recognized as an internal or external command, operable program or batch file
    The Qt command prompt set the shell PATH to find the components of the Qt SDK. If, and only if, you are using the bundled MingW compiler this is also present in the environment.

    You are using the Microsoft C++ compiler that expects a raft of stuff in its environment, the most important of which is the compiler/tool binaries in the PATH. When you use Microsoft's IDE this is all hidden for you (IMHO to the detriment of understanding). Microsoft, since at least the early '90s, provides a shell script called vcvars32.bat for Setting the Path and Environment Variables for Command-Line Builds (there may be a 64-bit version also). Execute this first after opening the Qt command prompt and you should find that things work better. You will need this to build Qt or any third party library, module etc. built from the command line: this is not unique to Qwt. I cannot tell you which version or where you have the Microsoft compiler installed so I cannot give you the exact command to type.

    I think it perfectly reasonable that every set of install instructions for a library, like Qwt, assumes that the programmer has a working compiler environment. To expect otherwise is to expect the library author to have access to every possible permutation of system and compiler and produce a blow-by-blow set of instructions for each. Having done that you can be 100% certain that they will still not match some programmer's particular environment, and they will complain. The majority of blogs and other attempts to provide blow-by-blow instructions for Qwt fail in that way and generally demonstrate the lack of understanding of the author.

  26. The following user says thank you to ChrisW67 for this useful post:

    ahmed ali (22nd March 2012)

  27. #20
    Join Date
    Mar 2012
    Posts
    19
    Thanks
    15
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Windows Symbian S60

    Default Re: How Can i Load data from file.ecg and plot it ?

    Master of zen << thanks a lot for your advice, but when i asked for a video tutorial this is as i am a beginner in Qt and i thought that i have something wrong in my setting.


    ChrisW67 << Lot of thanks for helping me, i have read your Reply and i will try it now.

Similar Threads

  1. Replies: 12
    Last Post: 31st October 2010, 17:08
  2. Load data from different ui
    By Xtresis in forum Newbie
    Replies: 2
    Last Post: 29th September 2010, 11:57
  3. Way to load all of data from 2 tables into one QTableView?
    By Kevin Hoang in forum Qt Programming
    Replies: 8
    Last Post: 3rd April 2010, 09:42
  4. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 17:02
  5. Replies: 6
    Last Post: 26th March 2009, 05:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.