Tuesday, July 5, 2011

Real time graph plotting in GUI with Qt creator

I used Qt creator as an platform for my final year project.
Reasons to choose Qt Creator:
1)It is extremely well documented
2)It runs in windows and Linux as well
3) It supports Open CV library
4)It's online help is available in  QT Forums
Ok let's get back to the point. I downloaded the qwt library and built the library
Qwt is dedicated library for graph plotting
I used Microsoft SQL server Management Studio as an Database Management studio. I am providing you straight away the in built library for QWT and my source code for real time plotting with database
Here is my .pro file in which I included the external library QWT as in my usual location. you can change your location as per required. Here I have used my C: as an location for the folder
Qwt library can be downloaded from http://sourceforge.net/projects/qwt/
Also the Details can be found in documentation http://qwt.sourceforge.net/ 
Details::
I also used QExtserial port library for recieving serial data in my gui. and I am plotting the serial data vs time in my GUI. QExtserialPort is also an external library as an qwt library.
It can be downloaded from http://sourceforge.net/projects/qextserialport/  . For more Details read the Documentation about this library from http://qextserialport.sourceforge.net/qextserialport-1.1.x/classQextSerialBase.html
I am providing you a Brief explanation for building the library.
1)Download the zip file and extract it in you drive let's say for example C:
2)Run the .pro file from the folder that you extracted
3) Under the built option run Qmake
4) After the Run operation you might get another folder containing lib(library folder )& include (folder containing classes i.e .h files)
With qwt folder in you C: and after running the .pro files you will get another folder like qwt-6.0.0 containg folder such as lib,include and doc
Then a path in .pro file in needed to link to the external library. You can check it out in .pro file.
If you still problem read this tutorial about building project files
QWT_LOCATION = C:/qwt-6.0.0
INCLUDEPATH += $${QWT_LOCATION}/src
INCLUDEPATH +=C:/qwt/src/
LIBS = -L$${QWT_LOCATION}/lib \
-lqwt
The above syntax is for linking external QWT library in our Qt project. 
 
 
Syntax for .pro file 
#-------------------------------------------------
#
# Project created by QtCreator 2011-06-02T17:26:29
#
#-------------------------------------------------
QT       += core gui
QT +=sql
QWT_LOCATION = C:/qwt-6.0.0
INCLUDEPATH += $${QWT_LOCATION}/src
INCLUDEPATH +=C:/qwt/src/
LIBS = -L$${QWT_LOCATION}/lib \
-lqwt
# The following section is to select static lib base on debug or release build
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
mac:LIBS = $$member(LIBS, 0) \
$$member(LIBS, 1)_debug
win32:LIBS = $$member(LIBS, 0) \
$$member(LIBS, 1)d
}
INCLUDEPATH += C:/qextserialport-1.2win-alpha
QMAKE_LIBDIR += C:/qextserialport-build/build
CONFIG(debug, debug|release):LIBS += -lqextserialportd
else:LIBS += -lqextserialport
unix: DEFINES = _TTY_POSIX_
win32: DEFINES = _TTY_WIN_
TARGET = excel
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui




3 comments:

  1. I am also trying to plot the graph two dimensional. I have used the qextserial port library but not getting how to use the qwt library. so please help me out.

    ReplyDelete
  2. I used Qt creator for plotting ECG waveform....but I get proper waveform. But I want to add gridview like graph paper...so how can I add this...please give me suggestion..Thnks

    ReplyDelete