Results 1 to 5 of 5

Thread: Graphs in Qt

  1. #1
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Graphs in Qt

    hi,

    i need to draw graphs in my qt project.
    as far as googling i came to know that to draw graphs in qt project , i need to use QWT.
    so i downloaded from sourceforge.net and it got installed taking the qt3 (as my sytem is linux where qt 3 is default and i manually install qt4.1( creator) .

    . so can any one guide me in using either qt4.1 or qt4.1+qwt to draw the graphs..


    Thanks in advance...

  2. #2
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphs in Qt

    Hi,
    I'm using ubuntu and installed Qt4.5.3. and Qwt 5.2.0

    Download Qwt 5.2. make all Files in the directory: chown -R a+rwx
    compile it with qt for the qwt examples..
    use:

    http://qwt.sourceforge.net/class_qwt_plot.html

    #include <qwt_plot.h>
    #include <qwt_plot_curve.h>

    QwtPlot *myPlot = new QwtPlot("Two Curves", parent);

    // add curves
    QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
    QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");

    // copy the data into the curves
    curve1->setData(...);
    curve2->setData(...);

    curve1->attach(myPlot);
    curve2->attach(myPlot);

    // finally, refresh the plot
    myPlot->replot();


    Or if you subclass your own
    class CMyPlot : public QwtPlot
    {
    ...
    }

    and draw the curves in the constructor...
    CMyPlot ::CMyPlot()
    {
    ...
    QwtPlotCurve cCurve = new QwtPlotCurve( PlotFileName1 );

    #if QT_VERSION >= 0x040000
    cCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    #endif
    cCurve->setPen(QPen(Qt::blue));
    cCurve->attach(this);
    cCurve->setData(Wavelength, Flux); // here your arrays must fit in
    ...
    }

    greetz Astronomy

  3. The following user says thank you to Astronomy for this useful post:

    qtlinuxnewbie (20th February 2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphs in Qt

    Thnk u very much for ur suggestion and sample program.
    but
    Download Qwt 5.2. make all Files in the directory
    i dint get u for the above lines.

    i hve installed my qt4.1 in the /opt directory.
    so can u help me in details where to (directories) install the qwt including the steps and also
    place the libraries.

    i have a doubt:
    can i use the qwt_plot.h directly in qt project??? after getting sucessfuly installed..

    Thnk u in advance...

  5. #4
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphs in Qt

    Hi,
    read the file INSTALL and/or Trolltechs qmake documentation. Once you have build the library you have to install all files from the lib, include and doc directories.
    http://qwt.sourceforge.net/qwtinstall.html

    Ah.. i've ment: make the directory + files: read/write/executable ( := rwx)
    Hmm.. why don't you install Qt4.5 or Qt4.6? Follow the instructions and everything is fine.

    in short:
    No, do not include the file manually. First compile Qwt with Qt. this will make all libraries you need.
    You must set at the bottom of your Project file: *.pro these lines:

    INCLUDEPATH += /home/orwherever/qwt-5.2/lib
    LIBS += -lqwt


    My Project settings look like: (in Qt/Project/Build Settings/Debug - Build Environment)
    LD_LIBRARY_PATH /opt/qtsdk-2009.04/lib/qtcreator:/home/orwherever/qwt-5.2/lib
    PATH /opt/qtsdk-2009.04/qt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/qwt-5.2/bin:/home/user/qwt-5.2/src
    PWD /home/user:/home/user/qwt-5.2/src
    QWTLIB /lib:/home/user/qwt-5.2/lib/:/home/workingdirectoryofapplication/bin/lib

    but some lines may be redundant..
    if your compiler didn't get through with -lqwt, install these libs. under ubuntu they are called libqwt and not lqwt!!! (i was looking a little time before i found out )

    greetz A.

  6. The following user says thank you to Astronomy for this useful post:

    qtlinuxnewbie (20th February 2010)

  7. #5
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphs in Qt

    thank you very much ..
    i will follw the steps and get back to u if necessasary..

Similar Threads

  1. Plotting graphs in QGraphicsView using qwt
    By luis_claudio in forum Newbie
    Replies: 0
    Last Post: 14th September 2009, 19:47
  2. Basic 2D Graphs with QGraphicsView
    By Astronomy in forum The GraphicsView Framework
    Replies: 3
    Last Post: 3rd August 2009, 21:07
  3. Double Buffering for plot graphs
    By Tavit in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 13:10
  4. Best way to draw x,y graphs
    By steg90 in forum Newbie
    Replies: 1
    Last Post: 14th May 2007, 11:52
  5. Drawing graphs
    By steg90 in forum Newbie
    Replies: 4
    Last Post: 9th May 2007, 13:37

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.