Results 1 to 2 of 2

Thread: Clicking on a plot

  1. #1
    Join Date
    May 2010
    Posts
    24
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Clicking on a plot

    I am using the spectrogram example code and I am a bit confused on how to detect a and respond to a mouse click (or mouse button press) on the spectrogram.

    Which object receives the mouse click? The spectrogram plot item? The plot's canvas, or the plot itself?

    Do I have to reimplement the mouse event function? Or are there signals from any of the above objects that I should be connecting to?

    On a related note, I need to modify the way the Zoomer class responds to mouse presses and I dont know how to do that. I'd like a left mouse click to just report the X,Y location on the plot, a right mouse press to start the zooming selection and a right mouse release to stop the selection and zoom, and finally a shift-right click to reset the zoom state back to the original.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Clicking on a plot

    Quote Originally Posted by Ronayn View Post
    Which object receives the mouse click? The spectrogram plot item? The plot's canvas, or the plot itself?
    The canvas.

    Note, that QwtPlotPicker offers an easy to use API to handle clicks on the canvas. F.e you have signals with the clicked position already translated into plot coordinates.

    I'd like a left mouse click to just report the X,Y location on the plot, ...
    Introduce an additional QwtPlotPicker and don't do this with your zoomer.

    .. a right mouse press to start the zooming selection and a right mouse release to stop the selection and zoom, and finally a shift-right click to reset the zoom state back to the original.
    Qt Code:
    1. zoomer->setMousePattern(
    2. QwtEventPattern::MouseSelect1, Qt::RightButton );
    3. zoomer->setMousePattern(
    4. QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ShiftModifier );
    To copy to clipboard, switch view to plain text mode 

    Don't forget to define the mouse bindings for stepping forward and backward in th zoom stack.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    Ronayn (29th April 2011)

Similar Threads

  1. Put plot axis out of the plot
    By KosyakOFF in forum Qwt
    Replies: 7
    Last Post: 21st June 2013, 13:36
  2. Clicking Instance problem..
    By anshumanBorah in forum Qt Programming
    Replies: 4
    Last Post: 18th April 2011, 15:24
  3. Clicking on QwtPlot
    By orignihn in forum Qwt
    Replies: 1
    Last Post: 14th April 2011, 16:37
  4. Double Clicking Pro File
    By BalaQT in forum Installation and Deployment
    Replies: 2
    Last Post: 18th November 2009, 05:23
  5. Replies: 7
    Last Post: 22nd September 2008, 22:05

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.