QMetaObject Compiler explain?

I am trying to know how Qt implements meta object compiling which enables them to provide signal slot mechanism in Qt. I am not able to finding much details in the documentation.

EDIT::I am not able to get the source code of _id = QObject::qt_metacall(_c, _id, _a);

Following is source file and corresponding moc file.

#ifndef SSOBJECT_H #define SSOBJECT_H #include <QObject> class ssObject : public QObject { Q_OBJECT public: explicit ssObject(QObject *parent = 0); signals: void readyToPrint(); void readyToPrint1(int); void readyToPrint2(float); private slots: int print(); }; #endif // SSOBJECT_H //output from MOC #include "../ssobject.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'ssobject.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 62 #error "This file was generated using the moc from 4.6.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_ssObject[] = { // content: 4, // revision 0, // classname 0, 0, // classinfo 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 3, // signalCount // signals: signature, parameters, type, tag, flags 10, 9, 9, 9, 0x05, 25, 9, 9, 9, 0x05, 44, 9, 9, 9, 0x05, // slots: signature, parameters, type, tag, flags 69, 9, 65, 9, 0x08, 0 // eod }; static const char qt_meta_stringdata_ssObject[] = { "ssObjectreadyToPrint()readyToPrint1(int)" "readyToPrint2(float)intprint()" }; const QMetaObject ssObject::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_ssObject, qt_meta_data_ssObject, 0 } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &ssObject::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *ssObject::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *ssObject::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_ssObject)) return static_cast<void*>(const_cast< ssObject*>(this)); return QObject::qt_metacast(_clname); } int ssObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: readyToPrint(); break; case 1: readyToPrint1((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: readyToPrint2((*reinterpret_cast< float(*)>(_a[1]))); break; case 3: { int _r = print(); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; default: ; } _id -= 4; } return _id; } // SIGNAL 0 void ssObject::readyToPrint() { QMetaObject::activate(this, &staticMetaObject, 0, 0); } // SIGNAL 1 void ssObject::readyToPrint1(int _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } // SIGNAL 2 void ssObject::readyToPrint2(float _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } QT_END_MOC_NAMESPACE

Also explain how QObject::connect(ssobj1,SIGNAL(readyToPrint()),ssobj1,SLOT(print())) expands

-------------Problems Reply------------

You'll find some of the answers here.

The best way to figure this out is to download the source code and have a look.

Category:qt Views:2 Time:2010-01-31

Related post

  • Is it possible to generate a DLL using Turbo C/C++ compiler? 2009-11-03

    I need this for calling a C function from Java class (JNI) and I know that there are options to do this using "Microsoft Visual C++ compiler". (explained here) But I am interested to know if something similar can be done using TC or TCC. I don't have

  • Sealed keyword affects the compiler's opinion on a cast 2012-01-18

    I have a situation where I'd like the behaviour of the compiler explained. Given a little code: interface IFoo<T> { T Get(); } class FooGetter : IFoo<int> { public int Get() { return 42; } } The following compiles and runs: static class F

  • signing assemblies with a strong name, ok, but what if some 3rd party DLL isn't signed? 2010-11-22

    I understand the basic idea behind signing assemblies but have a problem when using Telerik or 2rd party DLLs. I have an .exe that uses 2 of my own .DLLs, the DLLs in turn make use of the Enterprise library DLLs and Telerik DLLs. I gave all my projec

  • Default values for array arguments 2011-08-17

    Just playing around a little with C++. What I really want to do is to be able to setup a function with default values defined for an array or pointer argument. To keep things simple, let's just use an array. Like so: void experimentA(char a[3] = {'a'

  • C++: Templates: Partial Specialization: Print Everything Template 2012-02-05

    Good day everybody! Having the following code: template<typename T, typename OutStream = std::ostream> struct print { OutStream &operator()(T const &toPrint, OutStream &outStream = std::cout) const { outStream << toPrint; retu

  • Explain the strange assembly of empty C `main` function by Visual C++ compiler 2010-07-29

    I just noticed some strange assembly language code of empty main method. //filename: main.c void main() { } disassembly: push ebp mov ebp,esp sub esp,0C0h; why on the earth is it reserving 192 bytes? push ebx push esi push edi ; good compiler. Its sa

  • Explaining different outputs of ++b and b++ using gcc C compiler 2011-12-30

    Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…) Doubt in C increment operator From what i have searched the behavior is undefined in some cases in C and the compiler takes some approach. I'm trying t

  • 1 final compiler error :( can someone explain in real simple for me 2012-04-29

    C:\Users\George\Desktop\linear_equation_calc\main.cpp||In function 'int main(int, const char**)':| C:\Users\George\Desktop\linear_equation_calc\main.cpp|101|error: 'calcparallelplugin' was not declared in this scope| ||=== Build finished: 1 errors, 0

  • Can anyone explain the gcc cross-compiler naming convention? 2011-04-20

    I have tried to understand the naming conventions behind the gcc cross-compilers, but there seems to be conflicting answers. I have the following three cross-compilers in my system: arm-none-linux-gnueabi (CodeSourcery ARM compiler for linux) arm-non

  • Explaining to someone why type casting isn't done automatically at compile time 2011-06-02

    Recently, while I was writing a brief introduction to C for Fortran programmers, one of said Fortran programmers asked me about type casting. To him, it did not really make sense that in C you have to explicitly cast variables instead of having the c

  • Explain strange Scala compiler behaviour 2011-08-14

    I am working with Scala in Eclipse. I have a Scala class/trait hierarchy, with something like: A.scala: trait A B.scala: trait B extends A C.scala: trait C extends B Except more complicated; too big to post as example. So, C depends indirectl

  • WPF / Xaml: tag not available. I just don't get it. Who can explain the compiler message? 2011-12-25

    I am new to WPF / Xaml. I tried to run a demo program to test WPF with NHibernate. I used the VmWrapperDemo but i cant get it compiled! <Window x:Class="VmWrapperDemo.View.WindowMain" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentatio

  • Could some one explain compiling Apache from source on Windows 2012-05-01

    I need to do this in order to run two Apache Services running in windows. I want one listening on the default ports 80 and 443; the other listening on something else for HTTP and HTTPS. I already have one Apache2.2 service running successfuly. Accord

  • How to lock compiled Java classes to prevent decompilation? 2008-09-08

    How do I lock compiled Java classes to prevent decompilation? I know this must be very well discussed topic on the Internet, but I could not come to any conclusion after referring them. Many people do suggest obfuscator, but they just do renaming of

  • Using the DLR for (primarily) static language compilation 2008-09-13

    I'm building a compiler that targets .NET and I've previously generated CIL directly, but generating DLR trees will make my life a fair amount easier. I'm supporting a few dynamic features, namely runtime function creation and ducktyping, but the vas

  • Is there any way to define a constant value to Java at compile time 2008-09-19

    When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differentiate builds of the library. I got this by returning a #define in the code:

  • Xcode: 'Generics are not supported in -source 1.3' compiler error? 2008-09-21

    just a quick question: I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line w

  • Compile errors in mshtml.h compiling with VS2008 2008-09-23

    I'm in the process of moving one of our projects from VS6 to VS2008 and I've hit the following compile error with mshtml.h: 1>c:\program files\microsoft sdks\windows\v6.0a\include\mshtml.h(5272) : error C2143: syntax error : missing '}' before 'co

  • Tips for speeding up build time on Linux using ANT, Javacc, JUnit and compiling Java classes 2008-09-28

    We have a large codebase that takes approx 12 minutes on the developer machines to auto-generate some Java 5 classes using JavaCC and then compiles all the classes as well as running the units test. The project consists of multiple projects which can

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.093 (s). 11 q(s)