Results 1 to 1 of 1

Thread: Mouse cursor position on canvas

  1. #1
    Join Date
    Dec 2014
    Posts
    9
    Thanks
    2

    Default Mouse cursor position on canvas

    Hello,

    I'm posting the proper procedure to get the cursor position inside the canvas.

    Qt Code:
    1. canvas()->installEventFilter( this );
    2. // sometimes qobject_cast<QwtPlotCanvas*>(canvas()) might me needed
    3.  
    4. bool PlotView::eventFilter(QObject *obj, QEvent *event)
    5. {
    6. if (event->type() == QEvent::MouseButtonPress)
    7. {
    8. QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
    9. X = mouseEvent->pos().x;
    10. invTransform( QwtPlot::xBottom, X);
    To copy to clipboard, switch view to plain text mode 
    Last edited by gavinmagnus; 4th October 2016 at 16:21.

Similar Threads

  1. view position of mouse position in GraphicsScene
    By Raghaw in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2012, 04:46
  2. Replies: 1
    Last Post: 19th April 2012, 09:49
  3. QGraphicsView - show mouse cursor position in status bar
    By mwgobetti in forum Qt Programming
    Replies: 5
    Last Post: 19th November 2011, 18:34
  4. Replies: 1
    Last Post: 10th July 2009, 09:54
  5. Replies: 7
    Last Post: 8th September 2006, 16:19

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.