[Qt-interest] emitting signal from another class

John McClurkin jwm at nei.nih.gov
Thu Jul 15 14:12:56 CEST 2010


John McClurkin wrote:
> Sajjad wrote:
>> Hello forum,
>>
>> I have a singleton class whose data are shared between different other 
>> classes. The Shared class has some signals defined.
>>
>> I am getting the following error when i try to emit sigal of the 
>> shared class from another class:
>>
>>
>>
>> ***********************************
>>
>> /home/studenter/sajis997/QtStuff/transformation/SharedWidgetData.h:79: 
>> error: ‘void SharedWidgetData::modelViewMatrixChanged()’ is protected
>>
>>
>>
>> ***********************************
>>
>>
>> the code that generated the error is follows:
>>
>>
>> ******************************************
>>
>> .....
>> .....
>> emit pSharedData->modelViewMatrixChanged();
>> ......
>> ......
>>
>> ******************************************
>>
>> It seems that the signals are by default protected. Is that so or i am 
>> getting it somewhere wrong.
>>
> 
> You are getting it wrong. Signals can be public, protected, or private, 
> just like any other class member. In your case you need to declare the 
> signal public.

Ooops. Signals are protected. Only the class that defines the signal can 
emit the signal. What you need is a public member function that emits 
the signal.



More information about the Qt-interest-old mailing list