In QwtPlot,I want to get current mouse position when I move mouse (not drag) in all the curve window areas.
I subclass a MainWindowMouseMoveEventTest from QMainWindow as curve window.
Then create a QwtPlot in MainWindowMouseMoveEventTest and set MainWindowMouseMoveEventTest as its parent,
then create a curve and a QwtLegend in QwtPlot , set MainWindowMouseMoveEventTest, QwtPlot and QwtPlot's canvas MouseTracking state true.
But when I move mouse to special areas like QwtLegend area and area beside scalar,the MainWindowMouseMoveEventTest's mouseMoveEvent is not called!!!
Unless I drag the mouse(press down and move) in this areas, the mouseMoveEvent is called.
Those special areas is marked by red circle in the screenshot:mouseMoveProblem.jpg
I try to figure out the reason but failed, and I have search many solving method but failed .And this problem have been bothering me for several days.
My code:
#include "mainwindowmousemoveeventtest.h"
MainWindowMouseMoveEventTest::MainWindowMouseMoveE ventTest(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
m_pPlot = new QwtPlot(this);
QwtLegend* legnd = new QwtLegend;
m_pPlot->insertLegend(legnd, QwtPlot::TopLegend);
//curve
QwtPlotCurve *curve = new QwtPlotCurve("abc");
curve->attach(m_pPlot);
QwtAbstractLegend * pLegend = m_pPlot->legend();
pLegend->show();
////
setMouseTracking(true);
m_pPlot->setMouseTracking(true);
m_pPlot->canvas()->setMouseTracking(true);
//setCentralWidget(m_pPlot);
centralWidget()->setMouseTracking(true);
}
MainWindowMouseMoveEventTest::~MainWindowMouseMove EventTest()
{
}
void MainWindowMouseMoveEventTest::mouseMoveEvent( QMouseEvent * )
{
}
Bookmarks