Hi!
Code:
Header
template <class D>
class Signal
{
public:
void signal(D);
signals:
void send(D);
};
template <class D>
class Signal
: public QObject
{
public:
void signal(D);
signals:
void send(D);
};
To copy to clipboard, switch view to plain text mode
cpp
template <class D> void Signal<D>::signal(D data)
{
emit send(data);
}
template <class D> void Signal<D>::signal(D data)
{
emit send(data);
}
To copy to clipboard, switch view to plain text mode
namespace plot{
Signal* xSignal;
}
//------------------------
plot::xSignal = new Signal();
QObject::connect(plot
::xSignal,
SIGNAL(send
(double)),
this,
SLOT(notImportant
(double)));
namespace plot{
Signal* xSignal;
}
//------------------------
plot::xSignal = new Signal();
QObject::connect(plot::xSignal, SIGNAL(send(double)), this, SLOT(notImportant(double)));
To copy to clipboard, switch view to plain text mode
Everything still works to compile here but in next step something happend
double data = 0;
plot::xSignal->signal(data);
double data = 0;
plot::xSignal->signal(data);
To copy to clipboard, switch view to plain text mode
This code should send a signal to notImportant() like this:
First to "Signal::signal(double)" which send signal to "Signal::send(double)" which is connected to "notImportant(double)".
But I can't compile when I add the last line I got an error message.
Line:
plot::xSignal->signal(data);
plot::xSignal->signal(data);
To copy to clipboard, switch view to plain text mode
Error message is:
error: undefined reference to `Signal<double>::signal(double)''
error: undefined reference to `Signal<double>::signal(double)''
To copy to clipboard, switch view to plain text mode
I am new to templates so it is propably someting wrong there.
Does any of you know whats wrong?
Thanks
Ubi
Sorry for my english, I am from Sweden
Bookmarks