[Qt-interest] Signals and child classes

Marcello Romani mromani at ottotecnica.com
Mon Mar 22 16:11:53 CET 2010


Frederic Tingaud ha scritto:
> Marcello Romani a écrit :
>> Hi,
>>      I've written a simple log class which inherits from QTextEdit.
>> It just adds a public slot, logMessage(const QString&), which I'd like 
>> to connect another object to.
>> The error I get is:
>>
>> Object::connect: No such slot QTextEdit::logMessage(const QString&)
>>
>> The source line where this happens is:
>>
>> connect(parser, SIGNAL(messageWaiting(const QString&)), logText, 
>> SLOT(logMessage(const QString&)));
>>
>> logText is declared QtLogText*, and before I call connect it's 
>> initialized like this: logText = new QtLogText();
>>
>> What I don't understand is why connect is referring to the base class, 
>> which obviously doesn't have the logMessage slot, instead of the child one.
>>
>> Thanks in advance.
>>
>>   
> Hi,
> You probably forgot the Q_OBJECT macro, didn't you ?
> 

Damn, what a stupid mistake!

Thank you very much.

-- 
Marcello Romani



More information about the Qt-interest-old mailing list