little logical question........
Hi
i had connected about 15 QActions to a common SLOT, but i am not able to find in my slot function from which QAction the SIGNAL is coming . I had coded something like this
Code:
for(int i=0; i<15; i++)
{
play_add_Act
[i
] = new QAction(this);
play_add_Act[i]->setText("Play list");
connect(play_add_Act[i], SIGNAL(triggered()), this, SLOT(addplaylist()));
}
i also tried to pass index variable in slot function, but Wysota said that we shouldn't pass parameters names or values in SIGNAL or SLOT macros
so how can i identify signal sender action??????
Re: little logical question........
how can i pass signal emitting object as a parameter in SLOT macro so i can easily access slot function
(is it possible like this )
Code:
connect(play_add_Act
[0],
SIGNAL(triggered
()),
this,
SLOT(addplaylist
(QAction *play_add_Act
[0])));
Re: little logical question........
You can try one of two things. Either use QObject::sender() to determine which action sent the signal or use QSignalMapper to identify the sending action using a number or string.
Re: little logical question........
thank q sir
hey guys whoever uses a single slot to a no' of connections it will be very very useful
see the syntax of it
Code:
QAction *action
= qobject_cast<QAction
*>
(sender
());