[Qt-creator] Crazy idea 202: main.cpp wizards

Jochen Becher jochen_becher at gmx.de
Sat Apr 20 09:20:59 CEST 2019

Creating JSON wizards is not rocket science, I created some for myself.
Just copy one of the existing wizards and change it to your needs.

Regards, Jochen

Am Mittwoch, den 10.04.2019, 17:39 +0200 schrieb Jason H:
> There are some things that just always happen in main.cpp, this is
> particularly true for QML stuff that happens for engine
> initialization.
> It would be cool if:
> 1. There was a wizard/automated way to add a QObject-derived class to
> the main.
> 1a. Insert #include <QQmlEngine> if needed
> 1b. insert qmlRegisterType<MyObject>("com.mycompany.%PROJECTNAME%",
> 1, 0, "MyObject");
> 2. Support the other QML registration functions
> qmlRegisterSingletonType
> 3. Register Enums and the like.
> There may be other non-QML template stuff appropriate in main. I
> don't know if this is hard or not but if there was a section:
> /* Begin QtCreator Wizard Generated code. Do not edit, code managed
> by QtCreator */
>  qmlRegisterType<MyObject>("com.mycompany.%PROJECTNAME%", 1, 0,
> "MyObject");
> /* End QtCreator Wizard Generated code */
> I also saw on stack exchange
> https://stackoverflow.com/questions/20089196/how-to-access-c-enum-from-qml
> where the example has a static declareQML() function that registers
> itself. I don't know if this is preferred or not. Seems like more
> code and would make something like this harder. But if that is to
> continue, maybe have a thing in the class creation wizard to do that,
> or use that as the place to trigger the qmlRegisterType in main.cpp?
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> https://lists.qt-project.org/listinfo/qt-creator

More information about the Qt-creator mailing list