ffffffffff
ffffffffff

Reputation: 25

Is it a way to make Qt signal with realization?

When I declare in ,my class signal

signal: void someSignal();

there is no way that someSignal will have realization? If I try to write something like

void someClass::someSignal()
{//something here
}    

I receive linkage error. So it is implemented somewhere, as far as I understand it is done by moc-compiler. So is it some way for me to write realization of the signal?

Upvotes: 0

Views: 132

Answers (4)

Zaiborg
Zaiborg

Reputation: 2522

the signals provide a prototype for a function in your class. when you connect the signal to a slot, the call of emit someSignal() will call the slot connected to it. so there is no need to define what your signal should do, cause the connected slot will do this.

soo long zai

Upvotes: 0

krlos_Aut92
krlos_Aut92

Reputation: 1

OK, but remember that the slot must have the same parameters as the signal and and not return( void ) ie:

emit someSignal( int pram1, int pram2 ) ------ signal

void someSignal( int pram1, int pram2 ) ------ slot

greetings

Upvotes: 0

fasked
fasked

Reputation: 3645

QT documentation says:

Signals are automatically generated by the moc and must not be implemented in the .cpp file

Therefore, there is no way to have implementation of signals. In fact, you need only call signals. If you want to use signal as common function, just declare and implement new function :)

Upvotes: 4

Youssef Bouhjira
Youssef Bouhjira

Reputation: 1631

No you don't need to do that, you only have to declare you signal and emit it using

 emit someSignal(pram1,pram2);

Upvotes: 0

Related Questions