Results 1 to 7 of 7

Thread: QwtScaleDraw for yaxis

  1. #1
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtScaleDraw for yaxis

    Hi,

    In my app I have a Plot which shows for example a Temperature curve. Additionally to this Plot I have small plots below showing Binary Information of alarm, Input or Relais states.

    e.g. I have 5 different Inputs. I have one plot with a yaxis from 0 to 9:
    0 & 1: First Input (0 = 0, 1 = 1)
    2 & 3: Second Input (2 = 0, 3 = 1)
    4 & 5: Third Input (4 = 0, 5 = 1)
    6 & 7: Fourth Input (6 = 0, 7 = 1)
    8 & 9: Fifth Input (8 = 0, 9 = 1)

    I want to display instead of 0 to 9, 0-1-0-1-0-1... on my left yaxis.

    Qt Code:
    1. class BinaryScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. BinaryScaleDraw(){
    5. }
    6. virtual QwtText label(int v) const{
    7. QString LabelText;
    8. int i;
    9. i = v % 2;
    10. LabelText = QString::number(i,2);
    11. return LabelText;
    12. }
    13. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QwtPlot *BinaryPlot;
    2. BinaryPlot = new QwtPlot(DataList.at(i)->NameWithoutNumber(),this);
    3. ui->verticalLayout->addWidget(BinaryPlot);
    4. BinaryPlot->setCanvasBackground(Qt::white);
    5. BinaryPlot->setAxisScale(QwtPlot::yLeft, 0, 2*DataList.at(i)->quantity()-1, 1);
    6. BinaryPlot->setAxisScaleDraw(QwtPlot::yLeft, new BinaryScaleDraw());
    To copy to clipboard, switch view to plain text mode 

    I tried it like this, but this does not work.

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

    Default Re: QwtScaleDraw for yaxis

    "virtual QwtText label(int v) const" is not overloading virtual "QwtText label(double v) const" !

    Uwe

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

    mikrocat (22nd January 2016)

  4. #3
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtScaleDraw for yaxis

    Thank You. This was very helpful.

    The idea is to have two or more Plots, which share the same x-Axis or else one plot with two or more yAxis one below the other. I found some help to this theme but couldnt find an example.

    If I use different plots i need to connect the axis (when i zoom in one plot i need to zoom in the others too) and the canvas need to be in a vertical layout with the other canvas. If i try this I get errors. Is there any way to do this?

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtScaleDraw for yaxis

    The idea is to have two or more Plots, which share the same x-Axis ...
    Check the plotmatrix example.
    ...or else one plot with two or more yAxis one below the other.
    svn export https://svn.code.sf.net/p/qwt/code/b...-6.1-multiaxes

    Uwe

  6. #5
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtScaleDraw for yaxis

    Quote Originally Posted by Uwe View Post
    Check the plotmatrix example.
    Okay I checked the example but there is still the problem. If I have for example on my first plot a y-axis with a scale from 100-600 and on the other plots just 0 and 1 the plots aren't exactley below each other.

  7. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtScaleDraw for yaxis

    Quote Originally Posted by mikrocat View Post
    Okay I checked the example but there is still the problem. If I have for example on my first plot a y-axis with a scale from 100-600 and on the other plots just 0 and 1 the plots aren't exactley below each other.
    Then you need to have a second look at the plotmatrix example.

    Uwe

  8. #7
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtScaleDraw for yaxis

    Sorry, it was friday. I changed the scaledraw of my yAxis after the alignVaxis was called. So the alignment was ruined.

    Thank You!

Similar Threads

  1. plotting multiple curves ( n-YAxis)
    By Abderrahim in forum Qwt
    Replies: 4
    Last Post: 15th December 2015, 19:53
  2. Problem with QwtScaleDraw
    By kanzaky in forum Qwt
    Replies: 3
    Last Post: 7th May 2013, 12:42
  3. QwtPlotZoomer not to change the yAxis scale
    By dontgonearthecastle in forum Qwt
    Replies: 6
    Last Post: 14th January 2013, 08:43
  4. LayoutDirectoin of QwtScaleDraw
    By jesse_mark in forum Qwt
    Replies: 1
    Last Post: 2nd November 2012, 07:31
  5. Replies: 2
    Last Post: 23rd May 2011, 09:01

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.