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. Retrieve changes made by user in ListView
Qt 6.11 is out! See what's new in the release blog

Retrieve changes made by user in ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 4 Posters 789 Views 3 Watching
  • 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.
  • B Offline
    B Offline
    Bert59
    wrote on last edited by
    #1

    Hi,
    I have a list view populated with data from a text file.
    The end user can make changes to these data in the ListView.
    I'm wondering how I can retrieve the changes made by the end user.
    Which signal is emitted when a value is changed and how can I retrieve it?
    Thank you

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      That depends entirely on how your delegate is written.

      If you are using LineEdit in your delegate, you can use onTextChanged slot, or editingFinished() signal to get the new value.

      (Z(:^

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bert59
        wrote on last edited by
        #3

        Thank you very munch.
        In fact I use a TextField in the delegate. So editingFinished works fine.

        Bys the way, maybe you have an idea on how I can select the text in a TextField with a double click on it?
        I couldn' find the double click signal in relation to the TextField.

        1 Reply Last reply
        0
        • SeeLookS Offline
          SeeLookS Offline
          SeeLook
          wrote on last edited by
          #4

          @Bert59, Did You add

          TextField {
            selectByMouse: true
            // ...
          }
          

          ?

          1 Reply Last reply
          1
          • B Offline
            B Offline
            Bert59
            wrote on last edited by
            #5

            No I had not selectbyMouse: true.

            The issue I have now is because the text is a floating point number like 1.06, the double click is only selecting 1 or 06 depending on the position of the mouse.
            How can I set to select all?

            Thank you

            J.HilkJ 1 Reply Last reply
            0
            • SeeLookS Offline
              SeeLookS Offline
              SeeLook
              wrote on last edited by
              #6

              Probably this is normal system behavior for selecting text.
              Try triple click to select the entire field.

              1 Reply Last reply
              1
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                If triple click does not do it, you can probably work around it by adding a MouseArea covering your text field - and handle the double click there.

                (Z(:^

                1 Reply Last reply
                0
                • B Bert59

                  No I had not selectbyMouse: true.

                  The issue I have now is because the text is a floating point number like 1.06, the double click is only selecting 1 or 06 depending on the position of the mouse.
                  How can I set to select all?

                  Thank you

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @Bert59
                  I'm using:

                  onActiveFocusChanged: activeFocus ? selectAll() : deselect()
                  

                  works fine


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  1
                  • B Offline
                    B Offline
                    Bert59
                    wrote on last edited by
                    #9

                    onActiveFocusChanged: activeFocus ? selectAll() : deselect()
                    is not working exactly as expected.
                    The text is selected when the cell gets the focus, not on a double click.
                    The following is working:
                    onReleased: {
                    selectAll()
                    }
                    But it looks weird so I was wondering is there is a cleaner way to achieve this.
                    Thanks for your feedbacks.

                    Comming back to the intial question "Retrieve changes made by user in ListView", editingFinished() works fine for getting the value changed by the user. But I also need to know the index of the item that has been changed in the ListView. How do I retrieve this?

                    J.HilkJ 1 Reply Last reply
                    0
                    • B Bert59

                      onActiveFocusChanged: activeFocus ? selectAll() : deselect()
                      is not working exactly as expected.
                      The text is selected when the cell gets the focus, not on a double click.
                      The following is working:
                      onReleased: {
                      selectAll()
                      }
                      But it looks weird so I was wondering is there is a cleaner way to achieve this.
                      Thanks for your feedbacks.

                      Comming back to the intial question "Retrieve changes made by user in ListView", editingFinished() works fine for getting the value changed by the user. But I also need to know the index of the item that has been changed in the ListView. How do I retrieve this?

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by J.Hilk
                      #10

                      @Bert59 said in Retrieve changes made by user in ListView:

                      Comming back to the intial question "Retrieve changes made by user in ListView", editingFinished() works fine for getting the value changed by the user. But I also need to know the index of the item that has been changed in the ListView. How do I retrieve this?

                      delegates do have an index property attached to them you can check that simply by (e.g.)

                      Component.onCompleted: console.log(index)
                      

                      you can simply access it in your editing finished "slot"


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      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