Nominate our 2022 Qt Champions!

Unable to assign QQuickAnchorLine to int

  • Hi,
    This simple QML program produces the error

    Unable to assign QQuickAnchorLine to int
    import QtQuick 2.0
    Rectangle {
        id: root
        visible: true
        width: 800
        height: 480
        color: "lightsteelblue"
        gradient: Gradient {
            GradientStop { position: 0.0; color: "lightsteelblue" }
            GradientStop { position: 1.0; color: "blue" }
        Image {
            id: image1
            width: 250
            height: 250
            source: "logo_white_text.png"

    What is this error??? The image displays, but does not get centered as planned?


  • Hi! Alignment is important together with fillMode. What you want to achieve is to center the image in the rectangle. This is done with: anchors.centerIn: parent.

  • @Wieland
    Thanks, that was quick!

    Before I posted this message, I had a look at the
    page and found no anchors members, so was lost.

    Of course, I forgot to look at all the inherited members...
    My bad!

    Thanks again @Wieland !

Log in to reply