Re: qmenu and dynamic slot
Make sure you are using Q_OBJECT in your header file and then the correct syntax for slots is the signature of the slot:
Code:
minvite
->addAction
(strInviteChannel,
this,
SLOT(invite
(QString)));
But then I guess you cant achieve what you want, so have a look at QSignalMapper or use sender() in your slot.
Re: qmenu and dynamic slot
Quote:
Originally Posted by
Lykurg
Make sure you are using Q_OBJECT in your header file and then the correct syntax for slots is the signature of the slot:
Code:
minvite
->addAction
(strInviteChannel,
this,
SLOT(invite
(QString)));
But then I guess you cant achieve what you want, so have a look at
QSignalMapper or use sender() in your slot.
Code:
...
void qnicklist::invite()
{
QString strNick
= this
->selectedItems
().
at(0)->text
();
qnicklist
::send(QString("INVITE %1 %2").
arg(strInviteChannel
).
arg(strNick
));
}
....
{
....
for (int i = 0; i < strOpenChannels.count(); i++)
{
QString strInviteChannel
= strOpenChannels.
at(i
);
if (strInviteChannel[0] == '#')
minvite->addAction(strInviteChannel, this, SLOT(invite()));
}
....
}
sender()->objectName() return null ..
and sender() cannot cast to string...
So how to do it by sender ? example ?
Re: qmenu and dynamic slot
Well QSignalMapper would be the better way and of course sender (which returns a QObject) can not converted to a string. How could it. And how should the program know which string you mean?????
So the idea was to put user data to your actions and then cast the sender() to an action and read the data back.
Re: qmenu and dynamic slot