problem with emiting a signal
Hello everybody. I'm just testing how to emit a custom signal . For example, i have a button and , when I press it, ai want a signal called MySignal to be emited. I've done that quite easy
I now declare this signal in the "h" file :
Code:
signals:
void MySignal();
The problem is in the "cpp" file where i define this signal:
Code:
void App1::MySignal()
{
}
When it compiles it gives the following error:
Code:
tmp/obj/release_shared/moc_app.o(.text+0x60):moc_app.cpp: multiple de
`App1::MySignal()'
tmp/obj/release_shared/app.o(.text+0x0):app.cpp: first defined here
What seems to be the problem ?
Re: problem with emiting a signal
you don't need to implement signal, the moc does it. you need just emit a signal like this
Code:
....
connect(myButton, SIGNAL(clicked()), this, SIGNAL(processButtonClick()));
....
void App::processButtonClick()
{
...
emit MySignal();
...
}
or in your case (of cource if you don't need to process a button click)
Code:
...
connect(myButton, SIGNAL(clicked()), myWidget, SIGNAL(MySignal()));
...
myWidget -- is the widget which has MySignal.
Re: problem with emiting a signal
10x ... :) i didn't know that.