[Qt-interest] getting inside the moc

Luca Ferrari fluca1978 at infinito.it
Mon May 11 09:50:43 CEST 2009


Hi all,
I'm just curious to understand how the moc and signal/slot works in qt. So I 
created a simple couple of classes with signals and slots and I'm having a 
look at the moc produced files.
As far as I can understand, the idea is to implement each signal with a 
function that wraps the arguments and invokes activate on the target object. 
In both signaller and receiver the qt_metacall implementation dispatches 
signals to the right slot, choosing the signal to issue depending on an 
integer index and invoking the target method depending on the same index (on 
the target class). So a signal is mapped as "signal function 2" and is 
invoked, on the target the slot connected (let's say slot number 3) is 
invoked.
So a lot of work is done by qt_metacall, and QObject:connect stores the 
matching between the two indexes.
However, not all the details are clear to me.
For instance, there is a string qt_meta_stringdata that contains a kind of 
prototype of signals and slots and their parameter names. What is its purpose 
and why it does not report duplicated values (e.g., duplicated variable 
names)?
And how are the array of signal and slots associated? In the qt_meta_data 
array there is something like:

 // signals: signature, parameters, type, tag, flags
      22,    8,    7,    7, 0x05,
      41,    7,    7,    7, 0x05,
      73,   54,    7,    7, 0x05,

but how has to be read the above map?
Is there any document about how the moc works and signals/slots are 
implemented?

Thanks,
Luca



More information about the Qt-interest-old mailing list