Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Unable to assign QQuickAnchorLine to int
Forum Updated to NodeBB v4.3 + New Features

Unable to assign QQuickAnchorLine to int

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 6.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    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
           horizontalAlignment:Image.AlignHCenter
            verticalAlignment:Image.AlignVCenter
            width: 250
            height: 250
            source: "logo_white_text.png"
        }
    }
    

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

    Thanks!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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.

      DiracsbracketD 1 Reply Last reply
      0
      • ? A Former User

        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.

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by
        #3

        @Wieland
        Thanks, that was quick!

        Before I posted this message, I had a look at the
        http://doc.qt.io/qt-5/qml-qtquick-image-members.html
        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 !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved