PDA

View Full Version : creating custom signal



aj2903
14th March 2009, 06:51
can we create custom signal in qt? if yes how can it be done?

spirit
14th March 2009, 06:59
yes, you can


class MyObject: public QObject
{
Q_OBJECT
....
signals:
void mySignal(int myParameter);
....
private:
void emitMySignal();
....
};

...
void MyObject::emitMySignal()
{
emit mySignal(10);
}
...


i.e. you need to inherits from QObject, add Q_OBJECT macro, define your signal in signals section, emit signal in some method using emit.

aj2903
14th March 2009, 07:06
thanks spirit.

mean this is how the signal should be connected

connect(this,SIGNAL(mySignal),this,SLOT(func1)); or

connect(class name ,SIGNAL(mySignal),this,SLOT(func1));

faldzip
14th March 2009, 07:59
thanks spirit.

mean this is how the signal should be connected

connect(this,SIGNAL(mySignal),this,SLOT(func1)); or

connect(class name ,SIGNAL(mySignal),this,SLOT(func1));
it should look like:


connect(pointerToSomeObject, SIGNAL(someSignal(parameterType)), pointerToSomeObject, SLOT(someSlot(parameterType)));

so your first version is almost correct - you forgot about patameter type, for example: mySignal(int) instead of mySignal

qt.itk.vtk.help
17th May 2013, 07:19
Here I found a nice explaination may be this helps to you
http://qtitkvtkhelp.blogspot.in/2013/05/customize-widget-creating-new-signal.html?view=sidebar

ChrisW67
17th May 2013, 08:43
4-year old thread... new record?

d_stranz
21st May 2013, 19:11
Should change the username to qt.itk.vtk.hopeless. For the life of me, I can't understand why people respond to ancient posts. Do they not read the date before replying?

Then again, given the user name and the name of the site in the link, this looks like self-serving spam to me.

osirisgothra
21st October 2013, 17:04
who is more helpless, the one replying to a 4-year-old post, or the one replying to the reply? (or in my case, the one replying to the one replying to the one who replied 4 years late :))

That link was self-serving alright, it probably is one of those traffic booster bots that go around posting replies like that just to boost traffic at the home site, even though the replies may seem legit, its just a way to boost traffic so they can get more exposure to their google text ads, and in turn make money, it ALWAYS comes down to money (always). And why? because the more money you have the better chance you have of getting girlfriend... so really it all comes down to that "other" thing (unless you are a girl, then it all just comes down to shoes).

Prashant Kumar
18th July 2019, 08:37
eight of helpless people ;)

d_stranz
18th July 2019, 16:27
I guess we're just not going to let this thread die, are we? ;)

swati777999
18th November 2021, 09:33
I guess we're just not going to let this thread die, are we? ;)

Here's the most recent reply to this immortal post.

Cheers!