Results 1 to 2 of 2

Thread: How to plot qwt graphs dynamically through events something like button click...

  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Lightbulb How to plot qwt graphs dynamically through events something like button click...

    I tried to plot qwt graphs on button click, but graph is not plotting on main window widget.
    In my application i am able to plot qwt graphs only in main window constructor . But i want to plot qwt graphs at run-time on some event like button click.

    please share if any one knows....

    Thanks

  2. #2
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to plot qwt graphs dynamically through events something like button click...

    QwtPlot is derive from a couple of classes of which QFrame is one.
    QFrame class is the base class of widgets that can have a frame
    When you call a painting method (e.g. replot()) on an instance of QwtPlot, you are ordering repainting of the widget QwtPlot. Not a main window.

    You need to try something like this

    MainWindow w;
    w.setCentralWidget(myPlot);


    If you need to add a curve to a plot on button click, do something like this..

    connent(addCurveButton, SIGNAL(clicked()), myPlot, SLOT(addCurve()));

    Where myPlot is an instance of MyPlot. MyPlot being a subclass of QwtPlot that declares a Slot addCurve.

    The implementation of addCurve should go like this...

    void MyPlot::addCurve()
    {
    //get the curve info (e.g. 1) open and read a file to get coordinates,
    //2) launch a dialog that allows a vector of points to be generated based on some input)

    QwtPlotCurve * curve = new QwtPlotCurve (name);
    curve->setSamples(_samples) ;
    curve->attach(this);
    replot();
    }

Similar Threads

  1. Replies: 0
    Last Post: 26th December 2013, 05:58
  2. Replies: 2
    Last Post: 29th May 2013, 20:57
  3. Replies: 4
    Last Post: 11th July 2011, 15:04
  4. Replies: 5
    Last Post: 17th June 2011, 12:12
  5. Double Buffering for plot graphs
    By Tavit in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 13:10

Tags for this Thread

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.