how to check if a signal in emited or not??
Hi Every one,
in .h file, i defined a signal like
Code:
signals:
void mySig(arg list);
-- assume it in a.h
in .cpp file inside a method i'm emitting the signal like
in another file, b.h
i've a slot
Code:
void mySlot(arg list same as mySig);
and inside b file constructor i'm connecting this mySig to mySlot.
How ll i ckeck that if that signal is emited or not? plz help.
Re: how to check if a signal in emited or not??
add qDebug in that place where you emit a signal.
Re: how to check if a signal in emited or not??
i do not really understand what you mean, but if you only want to check if you code works,
type "qDebug() << "signal/slot works"; (or what ever) and run your code to test... you'll see if the signal and slot are really connected
Re: how to check if a signal in emited or not??
Or just put a breakpoint on the signal and run the code. If the breakpoint is hit, the signal works.
Re: how to check if a signal in emited or not??
Quote:
Originally Posted by
spirit
add qDebug in that place where you emit a signal.
Thank you spirit for the reply. Actually i've declare the signal in .h but didn't define it in .cpp file.
Code:
a.h
a();
~a()
function();
signal:
void mySig(arg);// signal return type is void
and inside a function
Code:
a.cpp
function()
{
....
...
qDebug()<<"checking mySig";
emit mySig(arg);
qDebug()<<"mySig executed";
}
But is this the right way???
Re: how to check if a signal in emited or not??
actually, you don't need to define signals in cpp, because moc do it for you.
this code is ok
Code:
a.cpp
function()
{
....
...
qDebug()<<"checking mySig";
emit mySig(arg);
qDebug()<<"mySig executed";
}
Re: how to check if a signal in emited or not??
Quote:
Originally Posted by
spirit
actually, you don't need to define signals in cpp, because moc do it for you.
this code is ok
Code:
a.cpp
function()
{
....
...
qDebug()<<"checking mySig";
emit mySig(arg);
qDebug()<<"mySig executed";
}
Thank you very much. and 1 more question. if i'm emitting the signal in a.cpp,
and in b.cpp
Code:
connect(a.obj, SIGNAL(mySig(arg)),this, SLOT(mySlot(arg)));
where mySlot(arg), is a public slot in b.h
Is this rightway to connect Signal and slot belongs from different class?