26

I need to implement some plot like that or that in my app , it can be even something similar.

I made a search on Qt web site with no progress , and I saw Qwt package but nothing similar there.

Any ideas?

demonplus
  • 5,613
  • 12
  • 49
  • 68
Night Walker
  • 20,638
  • 52
  • 151
  • 228
  • Here is an [answer](https://stackoverflow.com/questions/7800460/how-do-you-plot-points-in-qt/7841265#7841265) with source code for plotting points in a QGraphicsView very easily (11 lines of code). It doesn't seem like it does it out of the box at first, but it is just because the Graphics View Framework is a lot more powerful than a standard painter. – phyatt Oct 20 '11 at 20:13

7 Answers7

34

I love QCustomPlot which is a Qt C++ library. It focuses on making good looking, publication quality 2D plots, graphs and charts and also has high performance for real-time visualization applications. You can get it here: http://www.qcustomplot.com/

Nejat
  • 31,784
  • 12
  • 106
  • 138
29

I strongly recommend Qwt.

Qwt is a mature, well-documented library and, I think it's fair to say, the standard solution for implementing plots and other display and control widgets in Qt.

If you need 3D plots, try QwtPlot3D.

Sam Dutton
  • 14,775
  • 6
  • 54
  • 64
  • 1
    How about [QCustomPlot](http://www.qcustomplot.com/)? It seems to be better option now. – Isaac Feb 22 '16 at 18:09
  • 4
    QCustomPlot allows either GPL or commercial. Qwt uses the LGPL license. This is something that you must consider based on the project you're working on. – rbaleksandar Jul 11 '16 at 11:57
8

I'm using Qwt for that. The trick is to use a step function (see last example by this link), and shift the data by 0.5, so that bars will be centered to ticks. Here is an example of what you can get with alpha blending and anti-aliasing enabled: my histogram. Hope, you will do even better ;-)

MadH
  • 1,498
  • 4
  • 21
  • 29
7

As an alternative to Qwt you might also consider qt-plotting-widget which may be a simpler option.

poleguy
  • 523
  • 7
  • 11
3

Qt 5.6 now includes Qt Charts 2.1, which supports bar charts (as well as 7 other kinds).

Attila Tanyi
  • 4,904
  • 5
  • 27
  • 34
  • Is it available in open-source distribution? I cannot seem to be able to use the `charts` module. – Violet Giraffe May 24 '16 at 05:43
  • 1
    @VioletGiraffe - It is available, but not included with the open-source distribution of 5.6. ("Open source users can build the module from the sources.") For some help with building with open source, see this thread: https://forum.qt.io/topic/66946/how-to-build-qt-charts-2-1-on-windows-7 – Attila Tanyi Jun 09 '16 at 12:08
2

Qt has no support for plotting out of the box.

The most basic solution is to use QGraphicsView. Simply render your plot using the various items.

Other than that, you can follow this thread. It contains a couple of pointer to plotting frameworks but I don't know how useful they are or whether they are still supported in Qt 4.x.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
1

QCustomPlot is really easy to get started and there is plenty of Cartesian plot types you can do. Having said that, performance-wise it is not as good as other people say if you intend to plot large time series all at once. It internally uses a QMap to store the data which means that for every data point you insert or remove when populating, there is going to be one allocation / release of memory to add the data point to the map. See this post for more information.

Another thing I don't like is that even for simple plots it uses internally a struct QCPData that stores 6 double values when you would normally need two (x and y). That is, it triples the amount of memory you need to display a time series.

Community
  • 1
  • 1
Darien Pardinas
  • 5,910
  • 1
  • 41
  • 48