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. [SOLVED] listwidget. remove an item not by index but by the name

[SOLVED] listwidget. remove an item not by index but by the name

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.1k 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.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    in the listwidget, how to remove the name of the item instead of the index number because the index number is not known. for example, in the listwidget, an item called "test" is added, eg, ui->listWidget->addItem("test"). how to remove that item without using an index number. i would simply like to remove the item "test" instead.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      You have to search for the item and get the index. Then you can remove it:

      • "findItems":http://doc.qt.nokia.com/4.7/qlistwidget.html#findItems
      • "takeItem":http://doc.qt.nokia.com/4.7/qlistwidget.html#takeItem

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on last edited by
        #3

        thank you Gerolf. findItems worked.

        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