Overloaded QwtPlotPicker::trackerText but no text near mouse pointer
Subject: Overloaded QwtPlotPicker::trackerText but no text near mouse pointer
Newsgroups: gmane.comp.graphics.qwt.general
Date: 2008-07-02 13:51:14 GMT
Hi,
I have overloaded QwtPlotPicker::trackerText for showing only Y-values beside
mouse pointer (tracking), but the result is not text at all; here is my code:
const int Size = 12;
double xval[Size] = {1,2,3,4,5,6,7,8,9,10,11,12};
double yval[Size] = {3,4,2,6,5,6,6,3,2,4,5,8};
class Zoomer: public QwtPlotZoomer
{
public:
Zoomer(QwtPlotCanvas *canvas)
: QwtPlotZoomer(canvas)
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText(const QwtDoublePoint &pos) const
{
QColor bg(Qt::white);
bg.setAlpha(200);
QVariant yValue = pos.y();
yValue = yValue.toInt();
QwtText text;
&nbs
p; text.setText(yValue.toString());
text.setBackgroundBrush( QBrush( bg ));
return text;
}
};
DataPlot::DataPlot(QWidget *parent):
QwtPlot(parent)
{
QwtPainter::setDeviceClipping(false);
#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
/*
Qt::WA_PaintOnScreen is only supported for X11, but leads
to substantial bugs with Qt 4.2.x/Windows
*/
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif
// Assign a title
setTitle("A Simple plot");
crv.setPen(QColor(Qt::darkBlue));
crv.setStyle(QwtPlotCurve::Lines);
crv.setRenderHint(QwtPlotItem::RenderAntialiased);
crv.setRawData(xval,yval,Size);
crv.attach(this);
// Axis
setAxisTitle(QwtPlot::xBottom, "Time/seconds");
setAxisScale(QwtPlot::xBottom, 1, 12);
setAxisTitle(QwtPlot::yLeft, "Values");
setAxisScale(QwtPlot::yLeft, 0, 15);
}
Dialog::Dialog(QWidget *parent)
:QDialog(parent)
{
DataPlot *plot = new DataPlot(this);
d_zoomer = new Zoomer(plot->canvas());
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(plot);
setLayout(layout);
resize(800,600);
}
I'm using QT-4.4 and Qwt-svn.
Where is the error?
Thanks
Giuseppe
------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________ qwt-interest mailing list qwt-interest <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qwt-interest
RSS Feed