Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I haven't looked at Qt in a long while. Do they still have the MOC?


Yes, it's still used for several reasons, including:

- enumerate the properties, signals, slots and other methods as well as decorations (classinfo) present in a class (this feature is called “type reflection”, which is common in scripted languages, but is also present in Java)

- get and set properties by name and without knowing th exact type of the property (though technically the latter is a product of the related, but independent Meta Type system)

- place calls to extracted member functions (the “invokable” functions) by name

- the last two features together allow us also to integrate C++ classes easily with other languages and IPC mechanisms without the need to write specialised parsers (D-Bus, EcmaScript, QML, but also the many bindings to Qt like Python or C#)

- instantiate types by simply having access to the meta object


Yes, Qt still uses moc. I leave it up to you to decide if that's a good thing or a bad thing.


I certainly don't think it's a bad thing. Seems like without a MOC the programmer would have to write more code or file all that meta data in a separate file. So it's all good.

I was just curious since I haven't touched Qt in years and this post implies it is moving toward more standard C++.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: