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. How to remove ListModel row in TableView qml
Forum Updated to NodeBB v4.3 + New Features

How to remove ListModel row in TableView qml

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

    Hi ,
    I have TableView in application .How to remove ListModel currentRow in TableView in qml.When I remove curent index of TableView gives an exeption like below.

    listModel.remove(componentTableView.currentRow);

    Console Output:

    QML ListModel: set: index -1 out of range

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      -1 means that there's no row selected. You should add a check about it before calling remove

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        halil sogut68
        wrote on last edited by halil sogut68
        #3

        Hi,

        I have added select previous row code like below but again console output gives exception.

        componentTableView.selection.select(componentTableView.currentRow-1);
        listModel.remove(componentTableView.currentRow);

        Console Output:
        QML ListModel: set: index -1 out of range

        How can I add a check about it before calling remove in qml code ?

        Thanks,

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Use an if to check wether currentRow is under 0

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            halil sogut68
            wrote on last edited by halil sogut68
            #5

            Hi ,

            Can you write code because I unresolved the problem when I use an if to check wether currentRow is under 0

            Thanks

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you show your actual code ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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