Results 1 to 13 of 13

Thread: Event handling after release of QwtPlotZoomer.

  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Event handling after release of QwtPlotZoomer.

    Hello Everyone,

    As we know, when we use QwtPlotZoomer, we draw a rectangle on the plot and after mouse release, the selected area get zoomed/focused.
    So here my question is, I want to do something after release of mouse or after zoom effect.

    I know I can use QEvent::MouseButtonRelease:, but that's not the task. Is their anything in QwtPlotZoomer itself, like signal/method which I can used for after mouse release.

    Thanks

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

    Default Re: Event handling after release of QwtPlotZoomer.

    In general it might be wrong to connect to mouse event, as the zoomer also works with key events.
    So the answer depends on what exactly you want to do.

    Uwe

  3. #3
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    I have to set QwtPlotMarker value.
    I have some lines(Marker) on the the plot, but due to zoom they get hidden behind the widget, so I just want to set it within the widget in that event.

    And Yes I have tried to connect with SIGNAL(zoomed),
    Qt Code:
    1. class PlotZoomer: public QwtPlotZoomer
    2. {
    3. public:
    4.  
    5. PlotZoomer(int xAxis, int yAxis, QWidget *canvas):
    6. QwtPlotZoomer(xAxis, yAxis, canvas)
    7. {
    8. //setTrackerMode(QwtPicker::ActiveOnly);
    9. setRubberBand(QwtPicker::RectRubberBand);
    10.  
    11. // RightButton: zoom out by 1
    12. // Ctrl+RightButton: zoom out to full size
    13. setMousePattern(QwtEventPattern::MouseSelect2,Qt::LeftButton, Qt::ControlModifier);
    14. setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton);
    15. //setZoomBase(true);
    16. }
    17. };
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. m_zoomP(new PlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, m_plot->canvas()))
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. connect(m_zoomP, SIGNAL(zoomed(const QRectF &rect)), SLOT(zoomed(const QRectF &rect)));
    To copy to clipboard, switch view to plain text mode 
    But unable to connect, got error like below,
    err_method_notfound(2304)[13984]: QObject::connect: No such signal QwtPlotZoomer::zoomed(const QRectF &rect)
    Last edited by npatil15; 21st January 2019 at 07:04.

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

    Default Re: Event handling after release of QwtPlotZoomer.

    I already gave you an explicit answer on how to handle changes of the scales. This question looks like just another version of the same question.

    Uwe

  5. #5
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    I'm not asking about how to handle the changes on scale but I want to know which signal get invoked on zooming using QwtPlotZoomer.
    As I know I can use zoomed signal, but in my case the signal not connecting its showing some error as mentioned already.
    I dont understand why signal is unable to connect ?

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

    Default Re: Event handling after release of QwtPlotZoomer.

    Quote Originally Posted by npatil15 View Post
    I'm not asking about how to handle the changes on scale but I want to know which signal get invoked on zooming ...
    The zoomer does nothing else than changing the scales ...

    Uwe

  7. #7
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    Okay, so it doesnt invoke any signal after zooming or during zooming ?
    Or else is their any possibility that I can invoke signal manually after zooming ?

    I'm not sure, but when I checked "qwt_plot_zoomer.h", it shows signal zoomed. So you mean it doesn't work here ?
    Qt Code:
    1. class QWT_EXPORT QwtPlotZoomer: public QwtPlotPicker
    2. {
    3. Q_OBJECT
    4. Q_SIGNALS:
    5. /*!
    6.   A signal emitting the zoomRect(), when the plot has been
    7.   zoomed in or out.
    8.  
    9.   \param rect Current zoom rectangle.
    10.   */
    11.  
    12. void zoomed( const QRectF &rect );
    13. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Event handling after release of QwtPlotZoomer.

    I mean, that you try to solve a problem that is related to scale changes, where zooming is one reason for those to happen. So don't spend any time on handling zooming in a specific way, when you have a solution, that covers all situations.

    Uwe

  9. #9
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    I'm not handling zooming in the specif way. Thats okay how it works. But after zooming their is something on my plot that gets hidden.
    Actually what happens, after zooming on, plot get zoomed, that's okay for me, but here I already have some QwtPlotMarker(Lines(Horizontal and vertical)) on the plot which are sets on some specific position(based on pixel of widget) and when I zoom on plot the lines get hidden behind the plot. So If I know that zoom has done, then I can again set this line within the widget.

    Yes I can get this lines back by just scroll again(as I have scroll event in that I can set the line as per the widget pixel area). So like that after zoom I want to set this line within the widget, so that lines always on the plot.

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

    Default Re: Event handling after release of QwtPlotZoomer.

    Quote Originally Posted by npatil15 View Post
    So If I know that zoom has done, then I can again set this line within the widget.
    The markers disappear, when their position gets outside the boundaries of the scales. So you have to adjust their positions according to scale changes.
    This solves the problem in a general way - not only, when scale changes happen because of zooming.

    I already gave you all the details in https://www.qtcentre.org/threads/699...-QwtPlotMarker. If there is something unclear please continue in this thread, but don't expect any further responses to this one until you have explained why you can't follow my advice.

    Uwe

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

    npatil15 (22nd January 2019)

  12. #11
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    Thanks, I got what you want to say,
    I have tried with your solution
    Qt Code:
    1. connect(m_plot->axisWidget(QwtPlot::xBottom), &QwtScaleWidget::scaleDivChanged, this, &OscilloscopeWidget::scaleChanged);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void OscilloscopeWidget::scaleChanged()
    2. {
    3. qDebug()<<"Scale Changed";
    4. }
    To copy to clipboard, switch view to plain text mode 
    But getting this error below, Where is the mistake ?
    oscilloscopewidget.obj:-1: error: LNK2019: unresolved external symbol "public: static struct QMetaObject const QwtScaleWidget::staticMetaObject" (?staticMetaObject@QwtScaleWidget@@2UQMetaObject@@ B) referenced in function "public: static class QMetaObject::Connection __cdecl QObject::connect<void (__cdecl QwtScaleWidget::*)(void),void (__cdecl OscilloscopeWidget::*)(void)>(class QwtScaleWidget const *,void (__cdecl QwtScaleWidget::*)(void),class OscilloscopeWidget const *,void (__cdecl OscilloscopeWidget::*)(void),enum Qt::ConnectionType)" (??$connect@P8QwtScaleWidget@@EAAXXZP8Oscilloscope Widget@@EAAXXZ@QObject@@SA?AVConnection@QMetaObjec t@@PEBVQwtScaleWidget@@P83@EAAXXZPEBVOscilloscopeW idget@@P84@EAAXXZW4ConnectionType@Qt@@@Z)

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

    Default Re: Event handling after release of QwtPlotZoomer.

    I have tried with your solution
    The second option from my resonse, that derives from QwtPlotMarker should be the better one.

    IBut getting this error below, Where is the mistake ?
    This is a linker error, that depends on what you are linking and how those objects have been build.
    The reason for this should be the same as the one that is responsible for the missing zoomed symbol.

    Uwe

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

    npatil15 (22nd January 2019)

  15. #13
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Event handling after release of QwtPlotZoomer.

    Okay,
    The 2nd solution works perfectly for me, without error.
    For the reference, mentioned the solution here,
    Qt Code:
    1. class YourMarker: public QwtPlotMarker
    2. {
    3. public:
    4. YourMarker( ... )
    5. {
    6. setItemAttribute( QwtPlotItem::ScaleInterest, true );
    7. }
    8.  
    9. void updateScaleDiv( const QwtScaleDiv& xMap, const QwtScaleDiv& ) override
    10. {
    11. const double margin = ...; // pixels
    12.  
    13. const double min = xMap.invTransform( xMap.p1() + margin );
    14. const double max = xMap.invTransform( xMap.p2() - margin );
    15.  
    16. setXValue( qBound( min, xValue(), max ) );
    17. }
    18. };
    To copy to clipboard, switch view to plain text mode 

    Thank you so much

Similar Threads

  1. Event Filter Mouse Press/Release Event not called
    By Alundra in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2016, 01:59
  2. Replies: 14
    Last Post: 17th January 2012, 10:01
  3. event handling...
    By xyzt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2008, 08:16
  4. Replies: 3
    Last Post: 4th December 2007, 11:04
  5. Event handling problem
    By Mel Seyle in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2007, 05:15

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.