webstar
18th April 2014, 19:29
et's say I have a string containing "function()", where function() is a slot in a class, and I would like to connect that slot with any signal, but using that string. Neither
QString f="function()";
connect (randomobject, SIGNAL(randomsignal()), this, SLOT(f));
or
QString f="SLOT(function())";
//conversion to const char*
connect (randomobject, SIGNAL(randomsignal()), this, f);
work.
Is there a way to do something similar? It's important that it's a string and not a function pointer.
QString f="function()";
connect (randomobject, SIGNAL(randomsignal()), this, SLOT(f));
or
QString f="SLOT(function())";
//conversion to const char*
connect (randomobject, SIGNAL(randomsignal()), this, f);
work.
Is there a way to do something similar? It's important that it's a string and not a function pointer.