Results 1 to 3 of 3

Thread: QwtPlotRescaler does not work

  1. #1
    Join Date
    Feb 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default QwtPlotRescaler does not work

    I need to make a plot with a fixed aspect ratio. It seems that QwtPlotRescaler is intended for this too, but I cannot make it work at all. I made a very simple example:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. this->setLayout(new QVBoxLayout(this));
    7. QwtPlot *plot = new QwtPlot(this);
    8.  
    9. QwtPlotCurve *curve = new QwtPlotCurve();
    10. QPolygonF points;
    11. points.append(QPointF(0, 0));
    12. points.append(QPointF(1, 1));
    13. curve->setSamples(points);
    14. curve->attach(plot);
    15.  
    16. // QwtPlotRescaler section start
    17. QwtPlotRescaler *rescaler = new QwtPlotRescaler(plot->canvas());
    18. rescaler->setReferenceAxis(QwtPlot::xBottom);
    19. rescaler->setAspectRatio(QwtPlot::yLeft, 1.0);
    20. rescaler->setRescalePolicy(QwtPlotRescaler::Expanding);
    21. rescaler->setEnabled(true);
    22. rescaler->rescale();
    23. plot->plotLayout()->setAlignCanvasToScales(true);
    24. // QwtPlotRescaler section end
    25.  
    26. this->setCentralWidget(plot);
    27. }
    To copy to clipboard, switch view to plain text mode 

    Without QwtPlotRescaler section I get what I expect: a simple plot with a single straight line going from (0, 0) to (1, 1) and two axes, both from 0 to 1. After adding QwtPlotRescaler section I get an empty plot - no line, no axes, no ticks.

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

    Default Re: QwtPlotRescaler does not work

    A plot->replot() is missing before setting up the rescaler.

    Uwe

  3. #3
    Join Date
    Feb 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QwtPlotRescaler does not work

    Thanks, the plot is visible now, but there is another question.

    With the Expanding rescale policy the interval that is represented by one pixel is fixed, which is often good, but in the initial window the plot is truncated (y axis is from 0 to 0.6 instead of 1.0). With the Fitting policy I can use setIntervalHint. How can I guarantee minimum showed interval with the Expanding policy?

Similar Threads

  1. Replies: 0
    Last Post: 10th April 2015, 15:05
  2. AutoScal affects QwtPlotRescaler
    By jesse_mark in forum Qwt
    Replies: 0
    Last Post: 28th November 2012, 16:00
  3. Replies: 0
    Last Post: 12th July 2011, 09:20
  4. Make QwtPlotRescaler reflect data changes
    By hector1984 in forum Qwt
    Replies: 1
    Last Post: 26th August 2010, 11:06
  5. Replies: 2
    Last Post: 13th December 2009, 21:27

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.