Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Building Qt Quick project in Visual Studio



  • I'm trying to build Qt QML project in Visual Studio 2019 using Qt Tools for Visual stuido and have one problem.
    In .pro file I have these lines:

    QML_IMPORT_NAME = PRJ1
    QML_IMPORT_MAJOR_VERSION = 1
    

    and in main.qml:

    import PRJ1
    

    These line are needed to import custom QML types.
    I converted .pro to .vcxproj via "Qt Tools for Visual stuido " and the converter didn't add "PRJ1" to vcxproj. When i start the program it crahshes with error that PRJ1 is not defined. If I remove "import PRJ1" it works but without custom types. How should QML_IMPORT_NAME and QML_IMPORT_MAJOR_VERSION be defined in visual studio project?



  • @Dmitry87 said in Building Qt Quick project in Visual Studio:

    I have the same problem. Where I have to config QML_IMPORT_NAME etc. in Visual Studio ?



  • I had the same problem when using VS2015.
    I tried qt example project openglunderqml did the same error.



  • You should consider using qmlRegisterType() function. Check the example here.
    Also, you can try to edit something in the .vcproj settings, as it has almost all of the .pro settings:
    VS settings


Log in to reply