can we create custom signal in qt? if yes how can it be done?
can we create custom signal in qt? if yes how can it be done?
yes, you can
Qt Code:
{ Q_OBJECT .... signals: void mySignal(int myParameter); .... private: void emitMySignal(); .... }; ... void MyObject::emitMySignal() { emit mySignal(10); } ...To copy to clipboard, switch view to plain text mode
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.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Cupidvogel (20th April 2015)
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:
Qt Code:
connect(pointerToSomeObject, SIGNAL(someSignal(parameterType)), pointerToSomeObject, SLOT(someSlot(parameterType)));To copy to clipboard, switch view to plain text mode
so your first version is almost correct - you forgot about patameter type, for example: mySignal(int) instead of mySignal
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Here I found a nice explaination may be this helps to you
http://qtitkvtkhelp.blogspot.in/2013...l?view=sidebar
4-year old thread... new record?
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.
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).
eight of helpless people
I guess we're just not going to let this thread die, are we?
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
d_stranz (18th November 2021)
Bookmarks