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
#include "qwt_global.h"
#include "qwt_plot_canvas.h"
#include "qwt_plot_picker.h"
{
Q_OBJECT
public:
virtual ~QwtSpectrogramPicker();
protected:
};
#include "qwt_global.h"
#include "qwt_plot_canvas.h"
#include "qwt_plot_picker.h"
class QWT_EXPORT QwtSpectrogramPicker : public QwtPlotPicker
{
Q_OBJECT
public:
explicit QwtSpectrogramPicker( QwtPlotCanvas * );
virtual ~QwtSpectrogramPicker();
protected:
virtual QwtText trackerText( const QPoint & ) const;
virtual QwtText trackerTextF( const QPointF & ) const;
};
To copy to clipboard, switch view to plain text mode
and qwtspectrogrampicker.cpp
#include "qwtspectrogrampicker.h"
#include "qwt_plot.h"
#include "qwt_plot_spectrogram.h"
QwtSpectrogramPicker
::QwtSpectrogramPicker( QwtPlotCanvas *canvas
):{
}
QwtSpectrogramPicker::~QwtSpectrogramPicker()
{
}
QwtText QwtSpectrogramPicker
::trackerText( const QPoint &pos
) const {
return trackerTextF( invTransform( pos ) );
}
QwtText QwtSpectrogramPicker
::trackerTextF( const QPointF &pos
) const {
QwtPlotItemList list
= plot
()->itemList
(QwtPlotItem::Rtti_PlotSpectrogram);
if (list.count() == 0)
return trackerTextF( pos );
else {
double z = sp->data()->value(pos.x(), pos.y());
text.sprintf( "%.4f, %.4f, %.4f", pos.x(), pos.y(), z );
}
}
#include "qwtspectrogrampicker.h"
#include "qwt_plot.h"
#include "qwt_plot_spectrogram.h"
QwtSpectrogramPicker::QwtSpectrogramPicker( QwtPlotCanvas *canvas ):
QwtPlotPicker( canvas )
{
}
QwtSpectrogramPicker::~QwtSpectrogramPicker()
{
}
QwtText QwtSpectrogramPicker::trackerText( const QPoint &pos ) const
{
return trackerTextF( invTransform( pos ) );
}
QwtText QwtSpectrogramPicker::trackerTextF( const QPointF &pos ) const
{
QwtPlotItemList list = plot()->itemList(QwtPlotItem::Rtti_PlotSpectrogram);
if (list.count() == 0)
return trackerTextF( pos );
else {
QwtPlotSpectrogram * sp = static_cast<QwtPlotSpectrogram *> (list.at(0));
double z = sp->data()->value(pos.x(), pos.y());
QString text;
text.sprintf( "%.4f, %.4f, %.4f", pos.x(), pos.y(), z );
return QwtText( text );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks