Hi, everyone.
I am using qwt-6.1.0 library. I want to draw scales inside the plot canvas. I have read the example which is given in QwtPlotScaleItem class reference and created a subclass of QwtPlot where in constructor I wrote this:
Qt Code:
  1. QwtPlotScaleItem *scaleItemY =
  2. new QwtPlotScaleItem(QwtScaleDraw::RightScale);
  3. scaleItemY->setBorderDistance(0);
  4. scaleItemY->attach(this);
  5. this->enableAxis(QwtPlot::yLeft, false);
  6.  
  7. QwtPlotScaleItem *scaleItemX =
  8. scaleItemX->setBorderDistance(0);
  9. scaleItemX->attach(this);
  10. this->enableAxis(QwtPlot::xBottom, false);
To copy to clipboard, switch view to plain text mode 
Here everythig is ok. When I attach grid it cross labels, and now I want to shift labels, so that there would be no intersections of grids and labels. For that I have created a subclasses (XScaleDraw and YScaleDraw) of QwtScaleDraw class where i override virtual void drawLabel (QPainter* painter, double value) const function: instead of
Qt Code:
  1. lbl.draw ( painter, QRect( QPoint( 0, 0 ), labelSize.toSize() ) );
To copy to clipboard, switch view to plain text mode 
I wrote (for X shift) :
Qt Code:
  1. lbl.draw ( painter, QRect( QPoint( 0+(int)(labelSize.width()/2), 0 ), labelSize.toSize() ) );
To copy to clipboard, switch view to plain text mode 
and for Y shift:
Qt Code:
  1. lbl.draw ( painter, QRect( QPoint(0, 0+(int)(labelSize.height()/2) ), labelSize.toSize() ) );
To copy to clipboard, switch view to plain text mode 
Now I set scale draw and after that problems arise:
Qt Code:
  1. QwtPlotScaleItem *scaleItemY =
  2. new QwtPlotScaleItem(QwtScaleDraw::RightScale);
  3. scaleItemY->setScaleDraw(new YScaleDraw);
  4. scaleItemY->setBorderDistance(0);
  5. scaleItemY->attach(this);
  6. this->enableAxis(QwtPlot::yLeft, false);
  7.  
  8. QwtPlotScaleItem *scaleItemX =
  9. scaleItemX->setScaleDraw(new XScaleDraw);
  10. scaleItemX->setBorderDistance(0);
  11. scaleItemX->attach(this);
  12. this->enableAxis(QwtPlot::xBottom, false);
To copy to clipboard, switch view to plain text mode 
XScale is drawn at the top (instead of bottom) and YScale is disappeared. Actually it happens even if I don't override virtual void drawLabel (QPainter* painter, double value) const function and create empty subclass of QwtScaleDraw. Any idea what is going on here?