TextArea in ListView delegate



  • Hi,

    I have a little problem. I'm using a ListView with a QAbstractItemModel. In the delegate I want to use a TextArea to edit the model data.

    @
    TextArea {
    text: model.text
    onTextChanged: model.text = text
    }
    @

    But the onTextChanged signal gets emitted, befor the TextArea gets filled with the model data. This clears all initial data in the model for the text role.

    Has anyone an idea, how to first load the model data and the connect the onTextChanged signal?



  • Hope your delegate is something like this. It does not clear the data in model. Which platform you trying ?

    @ Item {
    width: 200
    height: 50
    TextArea {
    text : model.text
    onTextChanged: {
    console.log("Text changed")
    model.text = text
    }
    }
    }@

    Do you want to really use the TextArea ? You can use TextInput as well.



  • The delegate is a whole editor for the model and works fine except for the text input.

    There are also a few TextField's in the delegate, which are also showing this behavior. But there I can use the onEditingFinished signal to write the data back to the model.

    I'm using Qt 5.3.1 on OSX 10.9.4 and Windows 7. The problem occurs on both platforms.



  • I tried the same on Windows platform. It is going fine. May be I'm trying bit different ? I don't know. Can you dump complete example somewhere. I can try and suggest based on your sample.



  • I build a test project for this issue.
    "Test Project":https://dl.dropboxusercontent.com/u/20141415/QML_CPP_MODEL_TEST.zip

    What I found during the rebuild was, that the issue only shows up, when setting the textMargin property of the TextArea.



  • I also found, that when setting the inputMask for the TextField, the issue also shows up for TextFields.


Log in to reply
 

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