On 30/09/14 15:35, Mitch Curtis wrote:

On 30/09/14 14:55, Matías Néstor Ares wrote:
Hi everyone!
I'm developing an app with Qt, and I'm having some issues.
I don't get a proper answer from the forums yet.
So I ask it here, sorry if it is not the correct place.

The problem description is on this post: http://qt-project.org/forums/viewthread/47948/ And a video of the symptom here: https://www.youtube.com/watch?v=1sHKnNZLzhs

Thanks In Advance


_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

A hacky solution is below. It's just to point out that the state (text input) should be stored outside the delegates, as people are mentioning - in this case, it's stored in textArray.

[snip]

A slightly neater but still hacky example:

import QtQuick 2.2
import QtQuick.Controls 1.2

ApplicationWindow {
    id: applicationWindow1
    visible: true
    width: 200
    height: 200
    title: qsTr("TextEdit on ListView Test")


    property var textArray: {
        var a = [];
        for (var i = 0; i < listView1.count; ++i) {
            a[i] = "";
        }
        a;
    }

    ListView {
        id: listView1
        x: 286
        width: 110
        boundsBehavior: Flickable.StopAtBounds
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottomMargin: 0
        anchors.topMargin: 0
        anchors.bottom: parent.bottom
        anchors.top: parent.top
        clip: true

        model: ListModel {
            Component.onCompleted: {
                for (var i = 0; i < 10; ++i) {
                    append({name: "Grey", colorCode: "grey"});
                    append({name: "Red", colorCode: "red"});
                }
            }
        }

        delegate: Item {
            width: 100
            height: 40
            Rectangle {
                width: 100
                height: 40
                color: colorCode
                TextEdit {
                    id: textEdit
                    font.pointSize: 23
                    anchors.fill: parent
                    text: index < textArray.length ? textArray[index] : ""
                    onTextChanged: textArray[index] = textEdit.text
                    font.bold: true
                    anchors.verticalCenter: parent.verticalCenter
                }
            }
        }
    }
}



_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to