Results 1 to 3 of 3

Thread: XYZ tracker for QwtPlotSpectrogram

  1. #1
    Join Date
    Mar 2010
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default XYZ tracker for QwtPlotSpectrogram

    Hi,
    I am trying to display the x,y coordinates and the z value under the mouse for a QwtSpectrogram. I have a made simple class derived from QwtPlotPicker to do this, I tried to copy the way QwtPlotPicker derives from QwtPicker, however I have failed, it will not link properly! It must be some simple C++ ism that I don't understand, I am hoping someone can point out my error, or point me to an existing class that already does this!?!

    Thank you.
    Eric

    The compiler warns me about:
    qwtspectrogrampicker.cpp:5: warning: 'QwtSpectrogramPicker::QwtSpectrogramPicker(QwtPlo tCanvas*)' redeclared without dllimport attribute: previous dllimport ignored
    qwtspectrogrampicker.cpp:10: warning: 'virtual QwtSpectrogramPicker::~QwtSpectrogramPicker()' redeclared without dllimport attribute: previous dllimport ignored
    qwtspectrogrampicker.cpp:14: warning: 'virtual QwtText QwtSpectrogramPicker::trackerText(const QPoint&) const' redeclared without dllimport attribute: previous dllimport ignored
    qwtspectrogrampicker.cpp:19: warning: 'virtual QwtText QwtSpectrogramPicker::trackerTextF(const QPointF&) const' redeclared without dllimport attribute after being referenced with dll linkage

    The linker complains:
    ./debug\qwtspectrogrampicker.o: In function `QwtSpectrogramPicker':
    C:\Data\Proj\Bellatrix/qwtspectrogrampicker.cpp:6: undefined reference to `_imp___ZTV20QwtSpectrogramPicker'
    C:\Data\Proj\Bellatrix/qwtspectrogrampicker.cpp:6: undefined reference to `_imp___ZTV20QwtSpectrogramPicker'
    C:\Data\Proj\Bellatrix/qwtspectrogrampicker.cpp:6: undefined reference to `_imp___ZTV20QwtSpectrogramPicker'
    C:\Data\Proj\Bellatrix/qwtspectrogrampicker.cpp:6: undefined reference to `_imp___ZTV20QwtSpectrogramPicker'

    ./debug\qwtspectrogrampicker.o: In function `~QwtSpectrogramPicker':
    C:\Data\Proj\Bellatrix/qwtspectrogrampicker.cpp:10: undefined reference to `_imp___ZTV20QwtSpectrogramPicker'

    ./debug\qwtspectrogrampicker.o:C:\Data\Proj\Bellatri x/qwtspectrogrampicker.cpp:10: more undefined references to `_imp___ZTV20QwtSpectrogramPicker' follow
    ./debug\moc_qwtspectrogrampicker.o:C:\Data\Proj\Bell atrix/debug/moc_qwtspectrogrampicker.cpp:51: undefined reference to `_imp___ZN20QwtSpectrogramPicker16staticMetaObject E'
    ./debug\moc_qwtspectrogrampicker.o: In function `_static_initialization_and_destruction_0':
    C:\Data\Proj\Bellatrix/debug/moc_qwtspectrogrampicker.cpp:43: undefined reference to `_imp___ZN20QwtSpectrogramPicker16staticMetaObject E'

    Here is my code:
    qwtspectrogrampicker.h

    Qt Code:
    1. #include "qwt_global.h"
    2. #include "qwt_plot_canvas.h"
    3. #include "qwt_plot_picker.h"
    4.  
    5. class QWT_EXPORT QwtSpectrogramPicker : public QwtPlotPicker
    6. {
    7. Q_OBJECT
    8. public:
    9. explicit QwtSpectrogramPicker( QwtPlotCanvas * );
    10. virtual ~QwtSpectrogramPicker();
    11.  
    12. protected:
    13. virtual QwtText trackerText( const QPoint & ) const;
    14. virtual QwtText trackerTextF( const QPointF & ) const;
    15. };
    To copy to clipboard, switch view to plain text mode 

    and qwtspectrogrampicker.cpp

    Qt Code:
    1. #include "qwtspectrogrampicker.h"
    2. #include "qwt_plot.h"
    3. #include "qwt_plot_spectrogram.h"
    4.  
    5. QwtSpectrogramPicker::QwtSpectrogramPicker( QwtPlotCanvas *canvas ):
    6. QwtPlotPicker( canvas )
    7. {
    8. }
    9.  
    10. QwtSpectrogramPicker::~QwtSpectrogramPicker()
    11. {
    12. }
    13.  
    14. QwtText QwtSpectrogramPicker::trackerText( const QPoint &pos ) const
    15. {
    16. return trackerTextF( invTransform( pos ) );
    17. }
    18.  
    19. QwtText QwtSpectrogramPicker::trackerTextF( const QPointF &pos ) const
    20. {
    21. QwtPlotItemList list = plot()->itemList(QwtPlotItem::Rtti_PlotSpectrogram);
    22. if (list.count() == 0)
    23. return trackerTextF( pos );
    24. else {
    25. QwtPlotSpectrogram * sp = static_cast<QwtPlotSpectrogram *> (list.at(0));
    26. double z = sp->data()->value(pos.x(), pos.y());
    27.  
    28. QString text;
    29. text.sprintf( "%.4f, %.4f, %.4f", pos.x(), pos.y(), z );
    30. return QwtText( text );
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

  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: XYZ tracker for QwtPlotSpectrogram

    QWT_EXPORT is for classes of the Qwt library only. Don't use it in classes of the application.

    Uwe

  3. #3
    Join Date
    Mar 2010
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: XYZ tracker for QwtPlotSpectrogram

    Thanks Uwe, that did the trick.

Similar Threads

  1. Google map on QwtPlotSpectrogram
    By sagittager in forum Qwt
    Replies: 4
    Last Post: 15th October 2011, 15:32
  2. Replies: 1
    Last Post: 3rd December 2009, 15:21
  3. howto get value at Tracker Point
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 9th February 2009, 10:53
  4. R6 Bill Tracker
    By croland in forum Qt-based Software
    Replies: 0
    Last Post: 16th October 2007, 20:02
  5. Trolltech Task Tracker on Linux does not work?
    By iw2nhl in forum General Discussion
    Replies: 4
    Last Post: 16th August 2007, 11:47

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.