hello.
Yes It is possible. I did it by subclassing QwtScaleDraw and reimplementing the method QwtText label(double value).
{
public:
CExpScaleDraw();
virtual ~CExpScaleDraw();
void ajustar();
protected:
virtual QwtText label
(double value
) const;
private:
int numDec;
};
class CExpScaleDraw : public QwtScaleDraw
{
public:
CExpScaleDraw();
virtual ~CExpScaleDraw();
void ajustar();
protected:
virtual QwtText label(double value) const;
private:
int numDec;
};
To copy to clipboard, switch view to plain text mode
QwtText CExpScaleDraw
::label(double value
) const {
bool salir = false;
int i = aux.count()-1;
while(i>=0 && !salir)
{
if(aux.at(i) == '0')
{
aux.remove(i,1);
i--;
}
else
salir = true;
}
if(aux.at(i) == '.')
aux.remove(i,1);
return aux;
}
QwtText CExpScaleDraw::label(double value) const
{
QString aux = QString::number(value,'f',4);
bool salir = false;
int i = aux.count()-1;
while(i>=0 && !salir)
{
if(aux.at(i) == '0')
{
aux.remove(i,1);
i--;
}
else
salir = true;
}
if(aux.at(i) == '.')
aux.remove(i,1);
return aux;
}
To copy to clipboard, switch view to plain text mode
And when you create the plot, just insert this:
CExpScaleDraw *expSD = new CExpScaleDraw();
qwtPlot
->setAxisScaleDraw
(QwtPlot::yLeft,expSD
);
CExpScaleDraw *expSD = new CExpScaleDraw();
qwtPlot->setAxisScaleDraw(QwtPlot::yLeft,expSD);
To copy to clipboard, switch view to plain text mode
I hope that helps.
Regards.
Bookmarks