Results 1 to 3 of 3

Thread: Auto scale, but no plot data

  1. #1
    Join Date
    Nov 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Auto scale, but no plot data

    Hi all,

    This is my first time posting, and my first time trying to use Qwt. I am presently working on Win7 with Qt 5.5.1, and Qwt 6.1.2. I am compiling with VS2013 32. Everything seems to be installed properly, and I am using creator with the Qwt plugin.

    I haven't found a lot of examples, but pieced a test program together with what I found and the Qwt documentation.

    Current issue...
    My program compiles and runs with no warnings.
    When I call (update plot), the plot will auto scale the axis to my data but the plot doesn't show any data. It is completely blank.

    I have a feeling it is something I am overlooking, or don't know about.
    I am stuck and would appreciate any pointers.

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. ui->qwtPlot->setTitle("Plot 1");
    8. ui->qwtPlot->setAxisTitle(QwtPlot::xBottom, "X axis");
    9. ui->qwtPlot->setAxisTitle(QwtPlot::yLeft, "Y axis");
    10. ui->qwtPlot->setCanvasBackground(Qt::white);
    11.  
    12. QwtPlotCurve testCurve("Test Curve");
    13.  
    14. QVector<double> x;
    15. QVector<double> y;
    16.  
    17. for(int i = 0; i<500; i++)
    18. {
    19. x.push_back(i);
    20. y.push_back(i*i);
    21. }
    22.  
    23. testCurve.setSamples(x, y);
    24. //testCurve.setRawSamples(x.data(), y.data(), y.size());
    25.  
    26. myCurve.setPen(QPen(Qt::red));
    27.  
    28. testCurve.attach(ui->qwtPlot);
    29.  
    30. ui->qwtPlot->replot();
    31. //ui->qwtPlot->show();
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 


    Also, I just set up another computer exactly the same as previously described, but with VS2010. Same results.

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Auto scale, but no plot data

    testCurve is on the stack and therefore gone, when you leave the constructor of MainWindow.
    Concerning examples: there are several in the official tarball.

    Uwe

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

    pdm (20th November 2015)

  4. #3
    Join Date
    Nov 2015
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Auto scale, but no plot data

    Uwe,

    I knew it was something I was overlooking. My plot looks great now.

    Thanks for the excellent library, and the assistance.

Similar Threads

  1. Replies: 1
    Last Post: 19th November 2014, 06:48
  2. Replies: 1
    Last Post: 9th September 2013, 07:50
  3. Auto scale of QwtPoltItem.
    By jesse_mark in forum Qwt
    Replies: 1
    Last Post: 24th June 2013, 21:16
  4. Auto scale a QGraphicsView
    By niluje in forum Qt Programming
    Replies: 4
    Last Post: 5th July 2011, 23:43
  5. 4 axis auto scale..
    By Vincenzo in forum Qwt
    Replies: 0
    Last Post: 22nd March 2009, 01:12

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.