verticalCenter in ListView (Delegate) not working



  • Hey guys! I'm currently working on an exercise that revolves around ListViews, delegates and so on.

    This is what my application currently looks like:

    http://www.directupload.net/file/d/4141/obiumyrm_jpg.htm

    All I want is to center the second column of text just like the first column. However, I only manage to get it to the top or the bottom of the row - never in the center.

    Can any of you point out my mistake why I managed to but the first column of text nicely into the row's center but can't get it to work on the second one? Thanks in advance! :)

    This is my source code:

    main.qml

    import QtQuick 2.3
    import QtQuick.Controls 1.2
    
    ApplicationWindow {
        id: root
    
    width: 800; height: 600   
    
    function readFile() {
        var request = new XMLHttpRequest()
    
        request.open('GET', 'qrc:/Kommilitonen.txt')
        request.onreadystatechange = function(event) {
    
    
            if(request.readyState == XMLHttpRequest.DONE)
            {
                console.log(request.responseText)
                view.model = JSON.parse(request.responseText)
            }
        }
    
        request.send();
    }
    
    ListView {
        id: view
    
        property real delegateOpacity: 0.5
    
        anchors {fill: parent; margins: 2}
    
        delegate: KommiDelegate {}
    
        spacing: 4
        cacheBuffer: 50
    }
    
    Component.onCompleted: {
        root.visible = true
        readFile();
    }
    

    }

    KommiDelegate.qml

    import QtQuick 2.3
    
    Rectangle {
    id: delegate01
    anchors{left: parent.left; right: parent.right}
    height: 100
    border.width: 2
    border.color: "lightsteelblue"
    radius: 10
    clip: true
    opacity: 0.5
    scale: 0.9
    
    NumberAnimation{
        id: animateOpacity
        target: delegate01
        properties: "opacity"
        from: 0.9
        to: 1.0
        easing {type: Easing.OutBack; overshoot: 500}
    }
    
    
    
    MouseArea {
        anchors.fill: parent
        onPressed: {
            if(parent.opacity == 0.5)
                parent.opacity = 1.0
            else
                parent.opacity = 0.5
            if(parent.scale==0.9)
                parent.scale = 1.0
            else
                parent.scale = 0.9
    
        }
    }
    
        Image {
            id: img
            anchors.left: parent.left
            anchors.leftMargin: 20
            source: modelData.image
            smooth: true
            opacity: 0.3
            Behavior on opacity {NumberAnimation{easing.type:Easing.OutQuad}}
    
        }
    
        Column {
            id: column
            height: 50
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: img.right
            anchors.leftMargin: 20
            Text{text: 'First Name: ' + modelData.forename}
            Text{text: 'Name: ' + modelData.name}
            Text{text: 'University Course: ' + modelData.course}
            Text{text: 'Age: ' + modelData.age}
    
    
        }
    
    
    
    
    
    ListView
    {
        anchors.left: column.right
        anchors.leftMargin: 20
        anchors.verticalCenter: parent.verticalCenter
    
        id: viewClass
    
        delegate: ClassDelegate {}
    
        spacing: 4
        cacheBuffer: 50
    
        model: modelData.modules
    }
    

    }

    ClassDelegate.qml

    import QtQuick 2.0
    
    
    Rectangle {
        id: classDelegate
        anchors{left: parent.left; right: parent.right}
        visible: true
    
            Column {
    
                id: column2
                Text{text: 'Description: ' + modelData.name}
                Text{text: 'ID: ' + modelData.identificationCode}
                Text{text: 'Severity: ' + modelData.severity}
                Text{text: 'Group: ' + modelData.lernenGroup}
            }
    

    }


Log in to reply
 

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