gpt4 book ai didi

c++ - 在 Qwt 中显示绘图值的工具提示

转载 作者:可可西里 更新时间:2023-11-01 18:37:57 28 4
gpt4 key购买 nike

我的应用程序中有一个 qwt 图。我想显示一个小工具提示来显示鼠标在曲线上指向的点的值。我发现我必须为此使用 QwtPlotPicker,但在我的代码中找不到任何合适的示例来实现它。我是 Qwt 的新手,所以如果有人能帮我解决这个问题就太好了。

谢谢,拉凯什。

最佳答案

作者自己说here :

A QwtPlotPicker gives you the current position of the mouse ( in screen and plot coordinates ). Then you need to find the closest points of your curves. You can use QwtPlotCurve::closestPoint(), but in most cases you can find a much faster implementation depending on the characteristics of your data. When you need to compare the mouse position with the lines between the points you need the pixel position of these points ( use QwtPlot::canvasMap ). Maybe looking at the CanvasPicker of the eventfilter example helps.

我在自己的类中实现了它,它是 QwtPlot 的子类。在构造函数中,我有以下内容:

QwtPlotPicker* plotPicker = new QwtPlotPicker(this->xBottom, this->yLeft, QwtPicker::CrossRubberBand, QwtPicker::AlwaysOn, this->canvas());
QwtPickerMachine* pickerMachine = new QwtPickerClickPointMachine();
plotPicker->setStateMachine(pickerMachine);
connect(plotPicker, SIGNAL(selected(const QPointF&)), this, SLOT(onSelected(const QPointF&)));

现在在我的类(class)中(this 指针指向的地方)我应该实现插槽 onSelected(const QPointF&) 它将给出绘图坐标。

关于c++ - 在 Qwt 中显示绘图值的工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13066035/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com