Results 1 to 4 of 4

Thread: zooming when mouse hovers axis-label

  1. #1
    Join Date
    Dec 2011
    Location
    Landau, Palatinate, Germany
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default zooming when mouse hovers axis-label

    Hello,
    I am new here and I also a newbie on programming with qwt.
    Now I hope I can find help here and maybe I can help someone others.

    I have a qwtPlot which works correct with zooming and panning.
    My problem is, I want to zoom in an other way:
    1. If my mouse is in the canvas, only the Y-axis should be zoomed.
    - I think that shouldn't be a problem.
    2. If my mouse is over the X-axis-label (time-label), only the X-axis should be zoomed.
    - Here's my problem: How can I detect, that the mouse is hovering the X-axis-label?
    Is this at all possible?
    Are there any ideas for a workaround, if not?

    Andreas

  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: zooming when mouse hovers axis-label

    1. If my mouse is in the canvas, only the Y-axis should be zoomed.
    - I think that shouldn't be a problem.
    For the panner use QwtPlotPanner::setAxisEnabled( bool ).
    For the zoomer you need to have one x axis, but when you use only one of the simple assign the other one: f.e zoomer->setAxis( QwtPlot::xTop, ... );
    2. If my mouse is over the X-axis-label (time-label), only the X-axis should be zoomed.
    - Here's my problem: How can I detect, that the mouse is hovering the X-axis-label?
    Install an event filter for the axis widget: plot->axisWidget( QwtPlot::xBottom )->installEventFilter( ... );

    • plot->axisWidget( QwtPlot::xBottom )->scaleDiv() returns the values of the ticks ( labels are on the major ticks )
    • plot->axisWidget( QwtPlot::xBottom )->scaleDraw()->labelRect() calculates the bounding rectangle of a labels.
    • plot->axisWidget( QwtPlot::xBottom )->scaleDraw()->scaleMap() translates widget coordinates ( f.e mouse clicks ) into plot coordinates and v.v.

    HTH,
    Uwe

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

    Andreas (15th December 2011)

  4. #3
    Join Date
    Dec 2011
    Location
    Landau, Palatinate, Germany
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: zooming when mouse hovers axis-label

    Thanks a lot for fast answering Uwe.
    I will try out your suggestion today or tomorrow and let you know, if this helps.

  5. #4
    Join Date
    Dec 2011
    Location
    Landau, Palatinate, Germany
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: zooming when mouse hovers axis-label

    Unfotunetelly I has to say, that there are some very urgent things which I has to do.
    So I can't try out your proposal in the next few days.
    But I thought a little bit about your post:
    - When I install an eventfilter, I think I must not check where my mouse is.
    I think QWT / QT handles it in the correct way.
    Because I already installed an eventFilter in the canvas and it works without checking the mouse coordinates.

    Is my assumption correct?

    Thank you in advance

Similar Threads

  1. Replies: 6
    Last Post: 4th November 2011, 06:51
  2. Qt Designer How to make Button work with webwiev and a Label shows Mouse Position?
    By heavy.is.happy in forum Qt Tools
    Replies: 3
    Last Post: 8th July 2011, 19:26
  3. What determines color of text shown as axis label?
    By DrunkenUFOPilot in forum Qwt
    Replies: 1
    Last Post: 24th March 2011, 18:55
  4. Replies: 2
    Last Post: 28th December 2010, 11:41
  5. how to get the position of mouse click on a label
    By qt_user in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2010, 09:14

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.