[Qt-interest] Runtime Error :- connect: No such slot ...

Sean Harmer sean.harmer at maps-technology.com
Fri Feb 19 14:19:39 CET 2010


On Friday 19 February 2010 12:33:05 Wm. G. Urquhart wrote:
> Andreas Pakulat wrote:
> > If you look at the API docs you'll notice that setText is not a slot,
> > its a normal member function. Hence QObject::connect is correct.
> 
> Ouch! Yes of course, and by adding / changing SigTest :
> 
> private slots:
>      void setLegend(const QString &) ;
> 
> if (connect(pTest, SIGNAL(Boo(const QString &)), this,
> SLOT(setLegend(const QString &)), Qt::QueuedConnection))
> 
> void SigTest::setLegend(const QString & msg)
> {
>      ui.pushButton->setText(msg) ;
> }
> 
> Success.
> 
> But with that said my original submission still stands, it still doesn't
> work even though the slots have been defined in the main UI header and
> implemented in source.
> 
> I can see why the original test doesn't work, after all it is a bit of a
> screamer, but why my original doesn't is beyond me.
> 
> I have since included the SignalTest class and the slot definition and
> implementation from SigTest in to my original application and it still
> doesn't work.
> 
> private slots:
> 	void setLegend(const QString &) ;
> 
> void MyApp::setLegend(const QString & msg)
> {
> 	ui->statusBar->showMessage(msg, 0) ;
> }
> 
> pTest = new SignalTest() ;
> if (connect(pTest, SIGNAL(Boo(const QString &)), this,
> SLOT(setLegend(const QString &)), Qt::QueuedConnection))
> {
> 	pTest->Start() ;
> }
> 
> Object::connect: No such slot MyApp::setLegend(const QString &) in
> MyApp.cpp:268
> Object::connect:  (receiver name: 'MyApp')

Look into the generated moc_sigtest.cpp file and check that the code 
implementing the slot call is actually being generated by moc. If the example 
works but your app doesn't work even with the same receiver then your app (or 
the app's build system) must be doing something differently.

Are you able to call the setLegend() function directly or do you get a linker 
error when you try it? Just wondering if you are picking up a stale include 
file from somewhere.

Cheers,

Sean



More information about the Qt-interest-old mailing list