Results 1 to 2 of 2

Thread: mouseMoveEvent not called when only move mouse (not drag) in QwtPlot

  1. #1
    Join Date
    May 2016
    Location
    China,Wuhan
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy mouseMoveEvent not called when only move mouse (not drag) in QwtPlot

    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 * )
    {

    }

  2. #2
    Join Date
    May 2016
    Location
    China,Wuhan
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: mouseMoveEvent not called when only move mouse (not drag) in QwtPlot

    I lookup the consist of qwtplot.
    In my program its internal widget's area like this.mouseMoveProblem2.jpg
    (But the yRight's area is not in the right edge of qwtplot?And I don't know which widget is in this right edge area.)

    And use installEventFilter for its every internal widget (ex:canvas,legend,axes and ect).

    MainWindowMouseMoveEventTest::MainWindowMouseMoveE ventTest(QWidget *parent)
    : QMainWindow(parent)
    {
    ...
    centralWidget()->setMouseTracking(true);

    setMouseTracking(true);
    canvas->setMouseTracking(true);
    canvas->installEventFilter(this);
    ....//other internal widgets also install
    }

    But there still is a area not responding.Shown in blue circle in the screenshot.

    A solution is adding following code in MainWindowMouseMoveEventTest's constructor:
    enableAxis( xRight, true );

    But I don't want to show xRight axis.
    So is there any other solution to it without showing xRight axis.
    Any help will be appreciated!Thank u!

    added: the mousemove event is responsed in virtual bool MainWindowMouseMoveEventTest::eventFilter(QObject * watched, QEvent * event);

Similar Threads

  1. Replies: 3
    Last Post: 9th October 2014, 17:56
  2. QDockWidget: difference between move() and mouse drag
    By MrRipple in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2013, 09:30
  3. Replies: 11
    Last Post: 19th September 2013, 23:00
  4. catching mouseMoveEvent on QwtPlot
    By grantbj74 in forum Qwt
    Replies: 2
    Last Post: 30th July 2012, 07:14
  5. mouseMoveEvent during drag is not fired
    By gruszczy in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 22:04

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.