[Qt-creator] Crazy idea 202: main.cpp wizards
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.
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
> 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
> 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,
> /* End QtCreator Wizard Generated code */
> I also saw on stack exchange
> 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
More information about the Qt-creator