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

Qt Creator only recognize type of my custom QML component but the property does not



  • Qt Creator only recognizing the type of my custom qml component but the property inside the component does not.

    I registering the component with that option:

    qmlRegisterType(QUrl("qrc:/customcom/ViewApp.qml"), "com.mycompany.ui" , 1, 0, "ViewApp")
    

    then on main.qml

    import QtQuick 2.0
    
    import com.mycompany.ui 1.0 <-- I expect with this import option, make the code flexible and refactoring friendly
    
    ViewApp{
        id: viewApp
        anchors.fill: parent <-- Not Recognized by Qt Creator but can compile/run
    }
    

    Any advice?


  • Moderators

    So what does it not recognize? The parent (is there any)? Or anchors?



  • Qt Creator only can show auto-completion for Component Name (ViewApp) but cannot show completion for property inside the component (inside ViewApp.qml).

    How to make Qt Creator also can show completion of the property inside the component?


  • Moderators

    @kangherr said in Qt Creator only recognize type of my custom QML component but the property does not:

    Qt Creator only can show auto-completion for Component Name (ViewApp) but cannot show completion for property inside the component (inside ViewApp.qml).

    I see.

    How to make Qt Creator also can show completion of the property inside the component?

    Use qmldir (make a QML module) instead of qmlRegisterType. When using qmlRegisterType, place it in main.cpp, if it is in another class, Qt Creator gets lost easily.


Log in to reply