Cannot assign to non-existent property in another qml file



  • error is Cannot assign to non-existent property "marqueeText"
    i believe a qml file can call another qml by its filename but i got an error. Please enlighten

    @
    ===============marqueeText.qml==================================
    import QtQuick 2.0

    Rectangle {

        id:marqueeText
        height: scrollingText.height
        clip: true
        property int tempX: marqueeText.width
        property alias text: scrollingText.text
        Text {
            x: tempX
            id:scrollingText
            color: "Yellow" /* Hard code text color for now */
            font.pixelSize: marqueeText.height - 6;
        }
        Timer {
            id:timer
            interval: 200; running: true; repeat: true
            onTriggered:{
                tempX = tempX - 5
                scrollingText.x = tempX;
                console.debug("Tempx"+ tempX + "TextWidth = " + scrollingText.width, " Height = " + marqueeText.height)
    
                if( tempX < -scrollingText.width) {
                    tempX = marqueeText.width;
                    console.debug("Restartlling Text")
                }
               }
        }
    

    }
    @
    =========main.qml============================
    @
    import QtQuick 2.2
    import QtQuick.Window 2.1
    import QtQuick.Layouts 1.1
    import QtMultimedia 5.0

    Rectangle {
    width: 100
    height: 620
    id: screen

    Grid {
        columns: 2
        spacing: 0
    
        Rectangle {
            id: video;
            color: "black";
            width: 600;
            height: 432
            Video {
                id: videofile
                //playing: true
                source: "video/Bear.wmv"
                width: 600
                height: 432
                opacity: 0.9
                focus: true
                onStopped: {
                    videofile.play()
                }
            }
        }
        Rectangle {
            id: picture; width: 200; height: 432
            anchors.left: video.right
            Image {
                source: "pic/phone.jpg"
            }
        }
        Rectangle {
            id: text
            width: 800; height: 48
            color: "blue"
            marqueeText {                       //error
                id:scrolltext
                width: 800
                height: 48
                text: "Qt Quick Digital Signage Demo"
            }
        }
    

    }
    }

    @



  • Start the class name with an uppercase letter.

    I know, pretty non-intuitive.



  • you mean id to cap(MarqueeText) or filename & caller in main to cap



  • All three need to start with a cap.



  • You have probably already noticed that the id in marqueeText.qml should not start with an upper case letter as described "here":http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#the-id-attribute

    I main.qml you do
    @
    MarqueeText {
    id:scrolltext
    width: 800
    height: 48
    text: "Qt Quick Digital Signage Demo"
    }
    @

    This allocates a new instance of the MarqueeText class/element and has nothing to do with the id you provided in the MarqueeText.qml file


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.