Results 1 to 20 of 20

Thread: Regarding plotting using .csv file in QWT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,

    I tried to download qt csv file from below site:

    http://qcsv.svn.sourceforge.net/

    but when unzipped the file contains nothing, if you have csv file reader in Qt app download link please share.

    Thanks and Regards

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Regarding plotting using .csv file in QWT

    -- I am able to see the read csv values in the command prompt when I print them on the screen using qDebug() macro.
    You said this in an earlier post. If you are already able to read your data from the CSV file, then why are you wasting time downloading something from SourceForge? An if you go to the SF page you linked to , you will see that it clearly says:

    Files shown: 0
    so why are you surprised when your tarball is empty?

    Posting two images (one of which is clearly something made using a graphics editing program, not with Qwt) and asking "What am I doing wrong?" - How are we supposed to know? You have not shown us ANY SOURCE CODE AT ALL. How are we supposed to guess what you are doing wrong when you have told us absolutely nothing about what you are doing?

  3. #3
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,


    Please find the attached files of my application.

    Right now I am plotting the graph for 30 hard coded values , but they should be read from the csv files which are added as resources.

    Thanks in advance.
    Attached Files Attached Files

  4. #4
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi

    Does anybody has qwt example code which does dynamic plotting ? Please share the same.

    Thanks in advance.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Regarding plotting using .csv file in QWT

    I have looked at your code. It is clear to me from the fact that there are more lines of commented out code than there are non-commented lines that you really don't have any idea how to do what you want. I think you are totally confusing things and making it more difficult than it is. From what I understand, you want to do two things:

    1 - Read time and temperature strings from a CSV file and convert them to numbers
    2 - Create a Qwt plot that displays the temperature vs . time values as a curve

    First, you have to understand that reading the data and plotting the data are completely unrelated activities. So don't mix them all up in the same method (or even the same C++ class). Make a C++ class whose job is to read the data file and return the x and y arrays of doubles. It basically needs three methods and a couple of arrays:

    Qt Code:
    1. class CSVReader
    2. {
    3. public:
    4. CSVReader() {}
    5.  
    6. // opens the CSV file, reads the data into time and temperature arrays, returns true if OK, false otherwise
    7. bool readDataFromFile( const QString & fileName );
    8.  
    9. const QVector<double> & temperature() const { return mTemperature; }
    10. const QVector<double> & time() const { return mTime; }
    11.  
    12. private:
    13. QVector<double> mTemperature;
    14. QVector<double> mTime;
    15. };
    To copy to clipboard, switch view to plain text mode 

    Next, use this class to read the data, then pass the data to your curve:

    Qt Code:
    1. CSVReader dataSource;
    2.  
    3. if ( dataSource.readDataFromFile( "myfile.csv" ) )
    4. {
    5. const QVector<double> & temps = dataSource.temperature();
    6. const QVector<double> & times = dataSource.time();
    7. curve->setSamples( times.data(), temps.data(), times.size() ); // makes a copy of the data
    8. }
    To copy to clipboard, switch view to plain text mode 

    That's about as simple as it gets. Please notice, any two QVector<double> instances could be used to build the curve. The fact that the vectors were created by reading a CSV file is completely irrelevant as far as the plot is concerned. A tiny spaceship could land on your PC and a little green man could step out and hand you two vectors, and they would work the same way as far as the plot is concerned.

  6. #6
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi Stranz,

    Thanks a ton for your useful post.

    I was bit stranded as to what to do and what am I doing wrong?

    I shall get back to you if I get some more new problems.

    Thank you.
    Aster

Similar Threads

  1. Plotting in 3D
    By FelixB in forum Qwt
    Replies: 1
    Last Post: 1st October 2010, 16:26
  2. Using QGLWidget for plotting
    By llemes4011 in forum Qt Programming
    Replies: 4
    Last Post: 28th July 2010, 14:40
  3. Replies: 0
    Last Post: 4th August 2009, 15:24
  4. Plotting graph of 1/x
    By Persoontje in forum Qwt
    Replies: 1
    Last Post: 20th March 2009, 14:26
  5. Plotting from Left to Right ??
    By dheeraj in forum Qwt
    Replies: 3
    Last Post: 3rd June 2008, 07:09

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
  •  
Qt is a trademark of The Qt Company.