Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Removing items from the QListWidget
Forum Updated to NodeBB v4.3 + New Features

Removing items from the QListWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 549 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.
  • B Offline
    B Offline
    BartoszT
    wrote on last edited by
    #1

    I use a list from which items are removed one at a time. The current list item is deleted. Deleting the second to last one always fails with the at () function error: index out of range.
    Iterating through the list is ok, it reads and displays all the elements of the list correctly
    There is more details

    4d014fef-8874-4dcb-830b-c766149b2aaa-image.png

    how to fix it?

    B 1 Reply Last reply
    0
    • B BartoszT

      I use a list from which items are removed one at a time. The current list item is deleted. Deleting the second to last one always fails with the at () function error: index out of range.
      Iterating through the list is ok, it reads and displays all the elements of the list correctly
      There is more details

      4d014fef-8874-4dcb-830b-c766149b2aaa-image.png

      how to fix it?

      B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      @BartoszT
      How do you "Deleting the second to last one"?
      Also by deleting currentItem()?
      Deleting by iterating should be careful, the index and size are changing.

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

        MY CODE works in signal button function

        void MainWindow::on_pushButtonDELETE_clicked()
        

        ListItem is deleted one by one for every button click
        Deleting is two lines of MY CODE as you see above

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

          Hi,

          AFAIR, you should use takeItem before deleting it.

          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
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved