Reputation: 65
I'm trying to compile a program (found here: http://sourceforge.net/projects/lisem/) by following the instructions said by the author. However, when compiling it in Qt Creator, it gives the error:
invalid conversion from 'QWidget*' to 'QwtPlotCanvas*' [-fpermissive]
for this line in LisUImapplot.cpp
186 picker = new MyPicker( MPlot->canvas() );
link to its header file (LisUImapplot.h) can be found on the same folder as the cpp file.
class MyPicker: public QwtPlotPicker
{
public:
MyPicker( QwtPlotCanvas *canvas ):
QwtPlotPicker( canvas )
{
setTrackerMode( AlwaysOn );
}
virtual QwtText trackerTextF( const QPointF &pos ) const
{
QColor bg( Qt::white );
bg.setAlpha( 100 );
QwtPlotItemList list = plot()->itemList(QwtPlotItem::Rtti_PlotSpectrogram);
QwtPlotSpectrogram * sp = static_cast<QwtPlotSpectrogram *> (list.at(1));
double z = sp->data()->value(pos.x(), pos.y());
QString txt = "";
if (z > -1e10)
txt.sprintf( "%.3f", z );
QwtText text = QwtText(txt);
text.setColor(Qt::black);
text.setBackgroundBrush( QBrush( bg ) );
return text;
}
};
I hope you can help me on this. Thank you!
I am using Qt 5.1.1 MinGW 32-bit and Qwt 6.1.0
Upvotes: 1
Views: 2839
Reputation: 1
Why do you do constructor?
MyPicker( QwtPlotCanvas *canvas ):
QwtPlotPicker( canvas ){}
In the old version of Qwt was QwtPlotPicker::QwtPlotPicker(QwtPlotCanvas canvas); In the Qwt 6.1. is QwtPlotPicker::QwtPlotPicker(QWidget *parent);
You have to do
MyPicker( QWidget *canvas ):
QwtPlotPicker( canvas ){}
Upvotes: 0
Reputation: 12931
QwtPlot::canvas() returns a QWidget
. Your MyPicker
constructor is expecting a QwtPlotCanvas
type parameter.
You can cast it to a QwtPlotCanvas
:
QwtPlotCanvas *canvas = qobject_cast<QwtPlotCanvas*>(MPlot->canvas());
if(canvas)
{
picker = new MyPicker(canvas);
...
}
Upvotes: 5