woboq / verdigris

Qt without moc: set of macros to use Qt without needing moc
https://woboq.com/blog/verdigris-qt-without-moc.html
GNU Lesser General Public License v3.0
638 stars 58 forks source link

Add replacements for QML_ELEMENT macro and friends #83

Open arBmind opened 3 years ago

arBmind commented 3 years ago

Qt5.15 introduced new macros to register QObject with the Qml type system. See "QtQml/qqml.h" header:

All these macros use Q_CLASSINFO internally. This can also be done with Verdigris.

Ideas and help is more than welcome!

arBmind commented 2 years ago

My current state of analysis is:

My sketchy plan:

  1. Add CMakeLists.txt to Verdigris.
  2. Create a Verdigris replacement for qt_add_qml_module.
    • This will require a deep knowledge of CMake and some inspiration from the cmake tools provided by Qt.
  3. Use compiler defines to build an qmltyperegistrations.cpp equivalent.
    • Option A: build an executable that when executed generates the .cpp file.
    • Option B: generate the #include statements with CMake and use some local type registration to effectively do the same.
    • Option C: generate the .json compatible to moc and use qmltyperegistrar to build the qmltyperegistrations.cpp.
  4. Once this works use some clever tricks to build an executable that generates the qmltypes.

Seems kinda impossible.