[Development] ListView + TextEdit tricky behavior

Keith Gardner kreios4004 at gmail.com
Tue Sep 30 15:39:48 CEST 2014


On Tue, Sep 30, 2014 at 8:35 AM, Mitch Curtis <mitch.curtis at digia.com>
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 listDevelopment at qt-project.orghttp://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.
>
>
>         delegate: Item {
>             width: 100
>             height: 40
>             Rectangle {
>                 width: 100
>                 height: 40
>                 color: colorCode
>                 TextEdit {
>                     id: textEdit
>                     font.pointSize: 23
>                     anchors.fill: parent
>                     text: textArray[index]
>

                    onTextChanged: textArray[index] = textEdit.text
>


>                     font.bold: true
>                     anchors.verticalCenter: parent.verticalCenter
>                 }
>             }
>         }
>     }
> }
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>
For the TextEdit, the item should just load and store directly to/from the
model, no array needed.
TextEdit {
    id: textEdit
    font.pointSize: 23
    anchors.fill: parent
    text: model.modelData.text
    onTextChanged: model.modelData.text = text
    font.bold: true
    anchors.verticalCenter: parent.verticalCenter
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140930/0a9fee5a/attachment.html>


More information about the Development mailing list