Hello,
What is wrong with:
menu->addAction("Curve 1",this, SLOT(addGraph(QString("Curve 1"))));
I want to give the function addGraph the argument "Curve 1".
Regards,
Arend
Printable View
Hello,
What is wrong with:
menu->addAction("Curve 1",this, SLOT(addGraph(QString("Curve 1"))));
I want to give the function addGraph the argument "Curve 1".
Regards,
Arend
You cannot pass argument values to Signal/Slot connects, the arguments are always provided by the signal and passed to the slot.
In your case, where you have a signal without argument and want the slot to be called with a single string argument, the best way forward is to use QSignalMapper.
Create a QSignalMapper instance and use it as the receiver for addAction(), using SLOT(map()).
Then add a mapping from your action to the desired string and connection the signal mapper's mapped(QString) signal to your slot
Something like this
Code:
mapper->setMapping( action, "Curve 1" );
Cheers,
_
Thanks for the quick answer, but how to add a second curve?
Read the docs for QSignalMapper, understand what it is doing, and repeat the mapping exercise for the second, third, fourth, and subsequent signals.
Thanks for the post...