c++ - Generating Qt Q_OBJECT classes pragmatically -


how might 1 go making q_object based class (one has signals and/or slots) through metaprogramming? don't care if it's templates or preprocessor, neither appears work , need too.

what want able bind arbitrary function things qt signals. qt signals incapable of this, boost signals are. so, need qt object can connect qt signal , forward on boost signal. i'll need bunch, nice automate.

the main problem appears be--no big surprise--the moc processor. doesn't understand basic preprocessing (except ifs) , apparently can't template classes either.

any ideas?

here's i've discovered qt moc system:

using of http://www.codeproject.com/kb/cross-platform/qt_reversing.aspx ...

since know generated object going have one, single slot, , nothing else (that's it's for) generating moc stuff preprocessor should possible, though maybe difficult.

most of information in qt_moc_data_???[] array can hard coded. line of interest seems slots , there'll one. rest can { 5, 0,0,0,1,14,0,0,0,0,0,0,0,0 ... slot line ...., 0}

the slot line described in above link.

the qt_moc_stringdata_??? needs like: #object_name "\0\0" (param > 1 ? param-1:0 count commas) "\0" #functionname #paramtypelist

i believe of can generated preprocessor. tricky part going slot line has contain numbers provide indexes qt_moc_stringdata_???

there's functions need generated, , variable of type qmetaclass or something... of stuff should straight forward exception of invoker, has reinterpret cast parameters.

still though, believe preprocessor can generate of , appears way this. got qtcenter forum use:

#ifdef myclass struct myclass : qobject {   ... qobject definition... }; #endif 

... , that's plain entirely insufficient task. answers people give make me wonder.

unfortunately, of course, magic going depend great deal on version of moc used.


i've found better, easier way make happen. i've started blog article series on creating monster. see http://crazyeddiecpp.blogspot.com/2011/01/quest-for-sane-signals-in-qt-step-1.html


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -