Hi, I made plot X axis with my own time labels (Qwt 5.0.0):
{
public:
TimeScaleDraw
(const QTime &base
): baseTime(base)
{
}
virtual QwtText label
(double v
) const {
if(b_time_list.size()>0)
{
if(v<b_time_list.size() && v>0)
{
msg1=b_time_list[v];
}
}
return msg1;
}
private:
};
class TimeScaleDraw: public QwtScaleDraw
{
public:
TimeScaleDraw(const QTime &base):
baseTime(base)
{
}
virtual QwtText label(double v) const
{
QString msg1="";
if(b_time_list.size()>0)
{
if(v<b_time_list.size() && v>0)
{
msg1=b_time_list[v];
}
}
return msg1;
}
private:
QTime baseTime;
};
To copy to clipboard, switch view to plain text mode
In print to paper slot I see X axis with labels:
double xn11=0, xk11=1200;
qwtPlot
->setAxisScale
(QwtPlot::xBottom, xn11, xk11
);
//x
qwtPlot->replot();
painter.setViewport(xp-40, yp+hp, wp, hp*3);
qwtPlot->print(&painter,rect,filter);
double xn11=0, xk11=1200;
qwtPlot->setAxisScale(QwtPlot::xBottom, xn11, xk11);//x
qwtPlot->replot();
painter.setViewport(xp-40, yp+hp, wp, hp*3);
qwtPlot->print(&painter,rect,filter);
To copy to clipboard, switch view to plain text mode
But than I add setAxisScaleDraw() I see X axis without time labels:
qwtPlot
->setAxisScale
(QwtPlot::xBottom, xn11, xk11
);
//xqwtPlot
->setAxisScaleDraw
(QwtPlot::xBottom,
new TimeScaleDraw
(QTime::fromString("00:00:00",
"hh,mm,ss")));
qwtPlot->replot();
painter.setViewport(xp-40, yp+hp, wp, hp*3);
qwtPlot->print(&painter,rect,filter);
qwtPlot->setAxisScale(QwtPlot::xBottom, xn11, xk11);//x
qwtPlot->setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw(QTime::fromString("00:00:00","hh,mm,ss")));
qwtPlot->replot();
painter.setViewport(xp-40, yp+hp, wp, hp*3);
qwtPlot->print(&painter,rect,filter);
To copy to clipboard, switch view to plain text mode
How can I print X axis with time labels?
Bookmarks