View Full Version : Anoying problem, Object::connect: No such slot

20th March 2011, 02:46
Hey everyone

I am bit new with qt4 and I have a program that is having a bit of problems connecting a button. I am not sure how much code I should provide, but in my header file have I created a slot:
void btnPressed( ros::Publisher& _publisher );

in my source file I then connect to the slot by:
connect( buttons.back() ,SIGNAL(pressed()), this, SLOT( btnPressed( publisherList.back() ) ) );

While it compiles fine, then during execution do I get:
Object::connect: No such slot SamplePlugin::btnPressed( publisherList.back() )

If I remove the use of input parameters for btnPressed, then it works fine, but the structure of my program is deeply depended that I can provide a publisher through connect(). I have searched alot on the net, seen people who have experienced same error message, but I could not find any error in my code and I have also seen examples of working code using input parameters, where I cant see much deviation from my own.
Is there anyone who have an idea what might be wrong?



20th March 2011, 09:09
Hi Sebastian!

You cannot pass a parameter in this way, sadly!

The proper qt way of doing this is with a QSignalMapper (http://doc.trolltech.com/latest/qsignalmapper.html).

Alternatives are to use QObject::sender() (http://doc.qt.nokia.com/4.7/qobject.html#sender) in your slot or to use the boost::bind (http://uint32t.blogspot.com/2008/11/using-boost-bind-and-boost-function.html) function or LibQxt's QxtMetaObject::bind (http://stackoverflow.com/questions/835914/qt-adapting-signals-binding-arguments-to-slots) as a slot, but thats either not nice Qt-OOP code or not easy to setup for a beginner.