Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Plot a Graph with Real Time Data



  • hi,

    I want to draw (plot) a graph in Qt creator with the real time data

    Is there any special procedure to draw a graph?

    can any one help me.

    Thanks in advance


  • Moderators

    Hi,

    For plotting, you need a 3rd-party library because Qt doesn't have its own plotting functions. Have a look at "Qwt":http://qwt.sourceforge.net/

    Someone else talked about his experiences here: http://technofreak-robotics.blogspot.com.au/2011/07/real-time-graph-plotting-in-gui-with-qt.html

    By the way, "Qt Creator" is the name of the "IDE":http://en.wikipedia.org/wiki/Integrated_development_environment; "Qt" is the name of the software library.



  • thanks for the reply.

    I found that QCustomPlot is also used to plot graphs. what is the difference between these two?


  • Moderators

    QCustomPlot is also a 3rd party solution and not part of the official Qt release.


  • Moderators

    [quote author="Swinetha" date="1372232893"]thanks for the reply.

    I found that QCustomPlot is also used to plot graphs. what is the difference between these two?[/quote]You're welcome. You'll have to ask someone who has used both Qwt and QCustomPlot before though -- I have never used them.

    Try reading their documentation to see what's different.



  • At first Itried to install qwt in my system.

    1st step
    /usr/local/Qt-5.0.2/bin/qmake qwt.pro
    its work fine.

    2nd step
    make

    but it's giving an error

    bq. cd src/ && ( test -e Makefile || /usr/local/Qt-5.0.2/bin/qmake /usr/local/qwt-6.1.0/src/src.pro -o Makefile ) && gmake -f Makefile
    Project ERROR: Unknown module(s) in QT: opengl
    gmake: *** [sub-src-make_first-ordered] Error 3

    any body know about this error?
    if knows please help me.



  • Yout Qt version had been built without the opengl module. If you want to use an OpenGL plot canvas you need to rebuild Qt with this module - but usually you are not intersted in this feature and you can simply disable this feature for Qwt: edit qwtconfig.pri.

    Uwe



  • hi, thanks for the reply. opengl means?

    to use this is there any procedure?

    you said that,

    bq. you can simply disable this feature for Qwt: edit qwtconfig.pri.

    How can I disable it? could you explain me please


  • Moderators



  • QCustomPlot doesn't require installing. The simplest mode of operation is to just include the qcustomplot.h and qcustomplot.cpp file, that's it.

    Of course, you can also compile a dynamic library from it, if you'd like.
    Have a look at the "QCustomPlot webpage":http://www.workslikeclockwork.com/index.php/components/qt-plotting-widget/ It offers an introductory tutorial that should get you started quickly.
    A new website is in progress with much more support material.



  • DerManu said that

    bq. The simplest mode of operation is to just include the qcustomplot.h and qcustomplot.cpp file, that’s it.

    From where can I add these files?

    Thanks in advance



  • [quote author="Swinetha" date="1372586436"]DerManu said thatFrom where can I add these files?[/quote]

    Just download the QCustomPlot.tar.gz package from the download section (at the bottom of the page). In there, you'll find the .h/.cpp files. Copy them to your local project directory, and add them to your project. In QtCreator, right click on the root project icon in the top left sidebar, select "Add Existing Files..." to do that.
    Then just #include "qcustomplot.h" wherever you need it (e.g. in your mainwindow.h).
    Have a look at the webpage, it's pretty well explained there. The examples project should also help alot in getting started (that's also in the download package).



  • Compile Qwt :
    Create visual studio project and copy only the header files and cpp files to the project and just compile. You can get the Qtw dll and libs.

    QCustomPlot : does not have that much performance when it comes to adding real time data.
    graph will lag after adding 100k points and will lag even more when few series are overlapped.

    i think Qwt is much better choice than QCustomPlot,, but lack documentation is big issue. They have few doxygen generated documents, but they will be of little help.


  • Lifetime Qt Champion

    Hi and welcome
    The mailing list is pretty good source for help combined with the samples.



  • Although this post is rather old, here's my two cents:

    http://stackoverflow.com/questions/32419897/drawing-simple-bar-charts-in-qml

    With QQuickWidget, you basically get a javascript accessible canvas that acts sort of like webkit's canvas (with some exceptions), and the javascript borrows from Chromium, minus the bulk of Chromium. I think it's v8 engine? Anyway, someone figured out how to port the chartjs.org project code over to this on Github. That means you can draw charts in Javascript, which is a whole lot easier than drawing them in other ways.


Log in to reply