PDA

View Full Version : Drawing a graphic?



ImNoob
25th November 2013, 14:59
Hi everybody,

I'm new at qt, so i have some questions.

i have a double array and it occurs 10 or 15 numbers. How can I draw a number line graphic according to these numbers? Which can i use components or objects? Do you know any examples about it? i didn't find an example exactly in internet.

Thanks

Ginsengelf
25th November 2013, 15:08
Hi, I'm not sure what you mean, so two interpretations:
- use QLCDWidget to show the numbers
- use QGraphicsView and friends to draw what you like.

Ginsengelf

Radek
25th November 2013, 17:29
If you need technical graphics then there is qwt - but do some training in qt itself first :)

ImNoob
25th November 2013, 17:50
Thanks for replies.

I want a number line like that:
9822

Is there any source code example or full project? I just want a graphic with 10 or 15 numbers.

Radek
25th November 2013, 18:00
I don't know whether there is a piece of source code available but your picture is exactly what qwt knows. Try google, search "qwt" and see.

ChrisW67
25th November 2013, 22:18
Or you could use QCustomPlot, which drew that graph in the first place. It is a GPL release: http://www.qcustomplot.com

ImNoob
26th November 2013, 09:31
Or you could use QCustomPlot, which drew that graph in the first place. It is a GPL release: http://www.qcustomplot.com

I tried this example but it didn't work: http://codingexodus.blogspot.com/2013/01/getting-started-with-qwt.html

No example doesn't work in my pc !!

Added after 1 22 minutes:

I found that example: http://doc.qt.digia.com/QtCharts/qt-charts-examples-linechart-example.html

But i can't use it. Because i can't find these libraries: #include <QChartView> #include <QLineSeries> . Help pls

Radek
26th November 2013, 15:24
What did not work on the blogspot example? The example seems to be enough simple.

Try not to use '-L' and '-l' when specifying the qwt library. I have a better experience with specifying libraries directly. With Linux it should be


LIBS += /usr/local/qwt-6.1.0-rc3/lib/qwt.so

With winblows it should be


LIBS += C:\path\qwt.lib


Beware of prefixes! Instead of qwt.so, you can have libqwt.so and so on. If you have libqwt.so then


LIBS += /usr/local/qwt-6.1.0-rc3/lib/libqwt.so

Check with your file manager. Also, with winblows, you should have both LIB and DLL. You link with the LIB and the DLL must be on your PATH.

ImNoob
26th November 2013, 17:35
What did not work on the blogspot example? The example seems to be enough simple.

Try not to use '-L' and '-l' when specifying the qwt library. I have a better experience with specifying libraries directly. With Linux it should be


LIBS += /usr/local/qwt-6.1.0-rc3/lib/qwt.so

With winblows it should be


LIBS += C:\path\qwt.lib


Beware of prefixes! Instead of qwt.so, you can have libqwt.so and so on. If you have libqwt.so then


LIBS += /usr/local/qwt-6.1.0-rc3/lib/libqwt.so

Check with your file manager. Also, with winblows, you should have both LIB and DLL. You link with the LIB and the DLL must be on your PATH.

Thanks Radek I added qwt_plot.h header file but i have this error: 'qwt_plot.h':no such file or directory

(i am using windows os)


I found this example: http://doc.qt.digia.com/QtCharts/qt-charts-examples-linechart-example.html

But where are these files:
#include <QChartView>
#include <QLineSeries>

And what is that: QTCOMMERCIALCHART_USE_NAMESPACE

Radek
26th November 2013, 17:46
Either you do not have headers at all (you have installed a "runtime", not a "development package") or your headers aren't at your local INCLUDE. Check with your file manager where are your headers, you can search "qwt_plot.h". Update INCLUDEPATH in your PRO file.

ImNoob
26th November 2013, 18:01
Either you do not have headers at all (you have installed a "runtime", not a "development package") or your headers aren't at your local INCLUDE. Check with your file manager where are your headers, you can search "qwt_plot.h". Update INCLUDEPATH in your PRO file.

I did all that you wrote. On the other hand i haven't these files:
#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>

But i have #include <qwt_curve.h> #include <qwt_grid.h>

Radek
27th November 2013, 08:20
qwt_plot_curve.h and qwt_curve.h seem to be almost the same headers. The same can be said for other "plot" and "no plot" headers. I have found "no plot" headers in qwt4 while the "plot" headers are in qwt6. It's a matter of versioning.

Try to replace missing "plot" headers with "no plot" ones and see. You need not pass, the headers aren't identical. Four your reference, there are links to sources (including headers) of qwt 4.2 and qwt 6.1:

qwt 4.2, "no plot": ftp://ftp-lcd.slac.stanford.edu/glast.u06/ISOC/src/PyQwt-4.2/qwt-sources/doc/html/index.html
qwt 6.1 "plot": http://qwt.sourceforge.net/dir_9ccb36e974cdad92d68e40b0bc8a6a19.html

My apologies for your problems. I did not imagine that newer qwt is so inconsistent with older versions :mad:

Uwe
6th December 2013, 14:19
My apologies for your problems. I did not imagine that newer qwt is so inconsistent with older versions :mad:
Come on: Qwt 4.x is from 2004 - written for Qt 2.x !

Uwe