Hello,
I'm posting the proper procedure to get the cursor position inside the canvas.
canvas()->installEventFilter( this );
// sometimes qobject_cast<QwtPlotCanvas*>(canvas()) might me needed
{
if (event
->type
() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent
= static_cast<QMouseEvent
*>
(event
);
X = mouseEvent->pos().x;
invTransform
( QwtPlot::xBottom, X
);
canvas()->installEventFilter( this );
// sometimes qobject_cast<QwtPlotCanvas*>(canvas()) might me needed
bool PlotView::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
X = mouseEvent->pos().x;
invTransform( QwtPlot::xBottom, X);
To copy to clipboard, switch view to plain text mode
Bookmarks