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. TextArea in ListView delegate
QtWS25 Last Chance

TextArea in ListView delegate

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 2.0k Views
  • 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.
  • L Offline
    L Offline
    levelxxl
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • L Offline
        L Offline
        levelxxl
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          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.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • L Offline
            L Offline
            levelxxl
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              levelxxl
              wrote on last edited by
              #6

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

              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