Undefined reference to signal
Hi all,
I have a problem that could be very stupid, but I'm not able to solve it.
I'm tring to be aware when an operator click with mouse on a qwtPlot, and have a class informed with a signal of the mouse position on the plot where he clicked.
These are the pieces of code.
Header:
Code:
#include <QMouseEvent>
#include <QDebug>
#include <qwt_plot.h>
{
public:
QwtPlotMy(int idPlotValue = 0);
signals:
void clickSignal();
private:
int idPlot;
};
Cpp:
Code:
#include "qwtplotmy.h"
QwtPlotMy::QwtPlotMy(int idPlotValue) :
{
idPlot = idPlotValue;
return;
}
{
emit (clickSignal());
qDebug() << "Into qwtplot"<<idPlot;
qDebug() << "x"<< event->x() << " - y"<< event->y() ;
return;
}
The problem is: compiling I get the message error:
Code:
undefined reference to 'QwtPlotMy::clickSignal()'
If I comment the "emit (clickSignal())" line everything works well and I have the mouse position in the debug messages. Where I missed something?
Thank you very much in advance,
Carlo
Re: Undefined reference to signal
you defined your signal in QwtPlotMy , but emit it from QwtPlotAnteo.
QwtPlotAnteo knows nothing about that signal.
Re: Undefined reference to signal
I'm sorry, High_flyer,
I changed the names o function and I forgot to change one.
No, this is not the problem, I send from QwtPlotMy, now I correct the names.
Re: Undefined reference to signal
You're missing the Q_OBJECT macro.
Re: Undefined reference to signal
Quote:
Originally Posted by
wysota
You're missing the Q_OBJECT macro.
I thought it was the macro missing, but if I put the "Q_OBJECT" line I have a lot of errors:
Code:
undefined reference to 'vtable for QwtPlotMy'
and I continue to have the usual error:
Code:
undefined reference to 'QwtPlotMy::clickSignal'
The code that I posted is related to a bigger project, where I use signals and slot without problems, so I don't think that the "undefined reference to 'vtable for QwtPlotMy'" can be that the libraries are not found by the linker, but maybe I'm wrong.
Re: Undefined reference to signal
Quote:
Originally Posted by
chinalski
I thought it was the macro missing, but if I put the "Q_OBJECT" line I have a lot of errors.
Because you didn't run qmake after adding the macro to an existing file.
Re: Undefined reference to signal
Quote:
Originally Posted by
wysota
Because you didn't run qmake after adding the macro to an existing file.
Thank you very much wysota (and High_flyer)! I knew it was something simple! I'm so sorry to have asked such a stupid question.
Goodbye
Re: Undefined reference to signal
Nevertheless your code won't work as you want to catch events of the plot canvas ( not the plot widget itsself ). Here you have to install en event filter instead of overloading mousePressEvent.
Uwe
Re: Undefined reference to signal
Quote:
Originally Posted by
Uwe
Nevertheless your code won't work as you want to catch events of the plot canvas ( not the plot widget itsself ). Here you have to install en event filter instead of overloading mousePressEvent.
Thank you Uwe, I'm studying the "bode" example to understand exactly what you said to me (I hope it is the right example).
In any case, I'm working with mouse press event now, because I'm working on my PC, but the target will be a touch event, because the real hardware will be a touch screen interface.
I think what you said will be the same, even on touch screen.
Bye, c