[Qt-interest] Runtime Error :- connect: No such slot (Update)
Wm. G. Urquhart
wgu at wurquhart.co.uk
Sat Feb 20 10:46:37 CET 2010
Andreas Pakulat wrote:
> On 20.02.10 08:41:21, Wm. G. Urquhart wrote:
>> Well this get weirder and weirder. In my code I have an existing slot
>> declared as:
>>
>> void typeChanged(int) ;
>>
>> when I 're-wire' my connect(...) to this slot it works, however; if I
>> change the code to use setLegendIndex(int) the connect(...) fails!
>>
>> Object::connect: No such slot MyApp::setLegendIndex(int) in myapp.cpp:302
>> Object::connect: (receiver name: 'MyApp')
>>
>> With setLegendIndex being declared thus:
>>
>> void setLegendIndex(int msg) ;
>>
>> and implemented using this:
>>
>> void MyApp::setLegendIndex(int msg)
>> {
>> ::QMessageBox::information(this, "Set Legend", tr("Value is
>> %1").arg(msg)) ;
>> }
>>
>> It was suspected that setLegendIndex was getting 'optimised' out but as
>> I use an if (...) to connect the signal I call the function when it fails:
>>
>> pTest = new SignalTest() ;
>> if (connect(pTest, SIGNAL(Boo(int)), this, SLOT(setLegendIndex(int)),
>> Qt::ConnectionType::QueuedConnection))
>> {
>> pTest->Start() ;
>> }
>> else
>> {
>> setLegendIndex(5) ;
>> }
>>
>> If I could be any more confused I would be, does anyone have any
>> suggestions here?
>
> Is setLegendIndex also declared as a slot? Did you forget the Q_OBJECT
> macro? If neither of these two is the problem please post a complete
> example showing the problem.
>
> Andreas
>
Hi Andreas,
You can see from the original thread that I have checked all of the
obvious things, setLegendIndex is declared as a SLOT and appears in the
MOC'd output:
case 55: setLegendIndex((*reinterpret_cast< int(*)>(_a[1]))); break;
as does the working slot:
case 42: typeChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
The problem with providing an example is I can't as both of my test
cases work!
More information about the Qt-interest-old
mailing list