Results 1 to 5 of 5

Thread: How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse ?

  1. #1
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse ?

    Hello, I want to display the pos(x,y) of the Axis draw by the class QwtPlot when my mouse drags, which works only when the mouse is in the axis area . My code is as follow:
    QwtPlotCanvas *canva = new QwtPlotCanvas(this);
    picker = new QwtPlotPicker(QwtPlot::xBottom,QwtPlot::yLeft,canv a);
    picker->setStateMachine(new QwtPickerTrackerMachine);
    picker->setTrackerMode(QwtPicker::AlwaysOn);
    But in fact, only a small area on the top left corner can display the pos(x,y) of the window instead of the axis which is really I want. Who can tell me what is wrong with my code? Thank you !

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

    Default Re: How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse

    When using Qwt from SVN trunk you have to insert the local canvas into a plot widget.

    For all other versions of Qwt the code above makes no sense, because you can't insert a local canvas - instead plot->canvas() needs to be the parent of your picker.

    Uwe

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

    æž—å©· (17th July 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse

    Quote Originally Posted by Uwe View Post
    When using Qwt from SVN trunk you have to insert the local canvas into a plot widget.

    For all other versions of Qwt the code above makes no sense, because you can't insert a local canvas - instead plot->canvas() needs to be the parent of your picker.

    Uwe
    I used qwt6.0,How can I judge whether it is from SVN trunk?And how to insert the local canvas into a plot widget? I tried to insert a line of code"picker->setParent(this->canvas());",it worked worse, I can't get the pos(x,y)even on the left top corner. Thank You!

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

    Default Re: How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse

    I used qwt6.0,How can I judge whether it is from SVN trunk?
    SVN trunk = Qwt 6.1.

    And how to insert the local canvas into a plot widget?
    You can't. Instead your code has to be:

    Qt Code:
    1. QwtPlotPicker *picker = new QwtPlotPicker( plot->canvas() );
    To copy to clipboard, switch view to plain text mode 
    Check the examples how to use picker/zoomer objects.

    I tried to insert a line of code"picker->setParent(this->canvas());",it worked worse, ...
    Of course - a second canvas not known by any layout and completely unrelated to the plot coordinate system ...

    Uwe

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

    æž—å©· (17th July 2012)

  7. #5
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How could I display the pos(x,y) of the axis designed by QwtPlot under the mouse

    I get it ! Thank you very much!


    Added after 39 minutes:


    Quote Originally Posted by Uwe View Post
    SVN trunk = Qwt 6.1.


    You can't. Instead your code has to be:

    Qt Code:
    1. QwtPlotPicker *picker = new QwtPlotPicker( plot->canvas() );
    To copy to clipboard, switch view to plain text mode 
    Check the examples how to use picker/zoomer objects.


    Of course - a second canvas not known by any layout and completely unrelated to the plot coordinate system ...

    Uwe
    Then how can I just display the integer ones of x axis?For I want to draw some histograms on the plot,and then display the value of the histograms.
    Last edited by æž—å©·; 17th July 2012 at 12:38.

Similar Threads

  1. QwtPlot x axis label
    By ldg20 in forum Qwt
    Replies: 5
    Last Post: 17th July 2012, 07:02
  2. QwtPlot - multiple axis
    By MukundanAR in forum Qwt
    Replies: 1
    Last Post: 7th March 2012, 07:53
  3. QwtPlot - multiple axis
    By MukundanAR in forum Newbie
    Replies: 0
    Last Post: 6th March 2012, 11:50
  4. QwtPlot legend with axis
    By desantossierra in forum Qwt
    Replies: 5
    Last Post: 20th January 2012, 14:05
  5. QwtPlot fixed X-axis display
    By micc13 in forum Qwt
    Replies: 2
    Last Post: 3rd December 2010, 12:28

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.