PDA

View Full Version : Auto-connecting slots for object *this*?



hickscorp
6th April 2007, 13:31
Hello,

I am trying to understand the behavior of the auto-connexion feature of signals->slots.
I have successfully connected various signals to slots, for instance using a method declaration named void on_btnDoIt_clicked(void) which perfectly works.

Now i am very lazy and want to make my code a bit more clear... I deleted the connect for a signal "finished"... And i'm guessing, how to auto connect it? I tried using on_this_finished(), on_self_finished() and on_finished()... None worked. What is the keyword to use to auto-connect a slot in the *current* object to the *current* object?

Thanks for your help ^^
Pierre.

[EDIT:]All my attempts were done using the default parametters of "finished" signal, a single int.

jacek
6th April 2007, 15:17
It seems that it's impossible to do it with QMetaObject::connectSlotsByName():

void QMetaObject::connectSlotsByName ( QObject * object ) [static]
Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:
void on_<widget name>_<signal name>(<signal parameters>);
You will have to write your own function that operates only on the given object, not its children.

hickscorp
6th April 2007, 15:22
Thank you, you answered to my question ^^