Results 1 to 7 of 7

Thread: QwtPicker with QwtHistogram

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QwtPicker with QwtHistogram

    It's much much clearer for me now. Thanks for the explanation.

    Using the "event_filter" example I found in the Qwt source, I tried to implement the move event, but it don't works. The "selected" works fine.

    Can I have some help on this piece of code ?

    HistogramPlot.hh
    cpp Code:
    1. #ifndef HISTOGRAMPLOT_HH_
    2. # define HISTOGRAMPLOT_HH_
    3.  
    4. # include <qwt_plot.h>
    5. # include <qwt_picker.h>
    6. # include <qwt_plot_picker.h>
    7.  
    8. class HistogramPlot : public QwtPlot
    9. {
    10. Q_OBJECT
    11. public:
    12. HistogramPlot(QWidget* = 0);
    13.  
    14. private:
    15. void populate();
    16.  
    17. private Q_SLOTS:
    18. void showItem(QwtPlotItem*, bool on);
    19. void moved(const QPoint& pos);
    20. void selected(const QPointF& pos);
    21.  
    22. protected:
    23. QwtScaleDiv fixedNumberScaleDiv() const;
    24. QwtPlotPicker* picker_;
    25. };
    26.  
    27. #endif /* !HISTOGRAMPLOT_HH_ */
    To copy to clipboard, switch view to plain text mode 

    HistogramPlot.cc
    cpp Code:
    1. HistogramPlot::HistogramPlot(QWidget* parent)
    2. : QwtPlot(parent)
    3. {
    4. [...]
    5.  
    6. picker_ = new QwtPlotPicker(this->canvas());
    7. picker_->setStateMachine(new QwtPickerClickPointMachine);
    8. connect(picker_, SIGNAL(moved(const QPoint&)),
    9. SLOT(moved(const QPoint&)));
    10. connect(picker_, SIGNAL(selected(const QPointF&)),
    11. SLOT(selected(const QPointF&)));
    12. }
    13.  
    14. void HistogramPlot::moved(const QPoint& pos)
    15. {
    16. QString info;
    17. info.sprintf("Freq=%g, Ampl=%g, Phase=%g",
    18. invTransform(QwtPlot::xBottom, pos.x()),
    19. invTransform(QwtPlot::yLeft, pos.y()),
    20. invTransform(QwtPlot::yRight, pos.y())
    21. );
    22. qDebug() << info;
    23. }
    24.  
    25. void HistogramPlot::selected(const QPointF& pos)
    26. {
    27. QString info;
    28. info.sprintf("Freq=%g, Ampl=%g, Phase=%g",
    29. invTransform(QwtPlot::xBottom, pos.x()),
    30. invTransform(QwtPlot::yLeft, pos.y()),
    31. invTransform(QwtPlot::yRight, pos.y())
    32. );
    33. qDebug() << info;
    34. }
    To copy to clipboard, switch view to plain text mode 

    Edit: I just understand that "moved" is use when you drag something, not when you move the mouse. I don't found a signal/slot which deal with mouse move. How can I implement that ?
    Last edited by cptpingu; 22nd November 2010 at 16:22.

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
  •  
Qt is a trademark of The Qt Company.