Results 1 to 6 of 6

Thread: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

  1. #1
    Join Date
    Dec 2007
    Location
    Genève
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Question setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    Hi all!

    Could you, please, help me?

    I've enabled yLeft and yRight on the QwtPlot.
    I'm using setAxisAutoScale and it works for yLeft, but the labels on yRight are not changing in the same way like yLeft does.... (actually, they're not changing at all, in AutoScale mode)

    But it works fine with logScale...

    Am I did something wrong?..

    basically, here is the code:

    Qt Code:
    1. if (baseWidget->isYLogScale()) {
    2. scaleEngineLeft = new QwtLog10ScaleEngine();
    3. scaleEngineRight = new QwtLog10ScaleEngine();
    4. }
    5. else {
    6. scaleEngineLeft = new QwtLinearScaleEngine();
    7. scaleEngineRight = new QwtLinearScaleEngine();
    8. }
    9.  
    10. plot->setAxisScaleEngine(QwtPlot::yLeft, scaleEngineLeft);
    11. plot->setAxisScaleEngine(QwtPlot::yRight, scaleEngineRight);
    12.  
    13. if (baseWidget->isYAutoScale()) {
    14. plot->setAxisAutoScale(QwtPlot::yLeft);
    15. plot->setAxisAutoScale(QwtPlot::yRight); //TODO: doesn't work :(
    16. }
    17. else {
    18. plot->setAxisScale(QwtPlot::yLeft, baseWidget->getYMin(), baseWidget->getYMax());
    19. plot->setAxisScale(QwtPlot::yRight, baseWidget->getYMin(), baseWidget->getYMax());
    20. }
    To copy to clipboard, switch view to plain text mode 

    thanx a lot!!
    Tim.

  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: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    Quote Originally Posted by Times View Post
    I've enabled yLeft and yRight on the QwtPlot.
    I'm using setAxisAutoScale and it works for yLeft, but the labels on yRight are not changing in the same way like yLeft does.... (actually, they're not changing at all, in AutoScale mode)
    The scales are calculated from the bounding rectangles of the plot items ( here your curves ), that are attached to it. If your curves are attached to the left axis they have no effect for the right axis.

    You can't attach a plot item to 2 y axes. So you have to synchronize the second y axis manually, or you insert an invisible dummy curve for the second y axis with the same bounding rect.

    Uwe

  3. #3
    Join Date
    Dec 2007
    Location
    Genève
    Posts
    9
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    Ok, thanks, but how can I synchronize the second y axis manually?
    is there something like
    "QwtPlot::getAxisScale (int axisId, double min, double max, double stepSize)" ?
    so, as far as i understand, i need these min, max and stepSize to do setAxisScale for the second y axis...

    in qwt_plot.h I found private class PrivateData; PrivateData *d_data;
    and private class AxisData; AxisData *d_axisData[axisCnt];

  4. #4
    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: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    These parameters are used for the calculation of the scale. The result of the calculation is a QwtScaleDiv. There are getters for the parameters, but you don't need to calculate the QwtScaleDiv twice.

    Probably the easiest way to synchronize the axes is to catch the scaleDivChanged signal of the left axis widget and to assign its QwtScaleDiv to the right one.

    Uwe

  5. #5

    Default Re: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    I'm having the same problem. It seems that a Qwt5.QwtPlotCurve is attached to yLeft by default. I would like to attach the curve to the yRight instead, is there an easy way to do it?

  6. #6
    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: setAxisAutoScale(QwtPlot::yRight) //doesn't work :(

    Qt Code:
    1. curve->setYAxis( QwtPlot::yRight );
    To copy to clipboard, switch view to plain text mode 

    Uwe

Similar Threads

  1. Printing via QPrinter doesnt work
    By mSergey in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2008, 19:00
  2. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  3. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20
  4. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 12:02

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.