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. Why code doesnt work?
Forum Updated to NodeBB v4.3 + New Features

Why code doesnt work?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Why this code doesnt work?
    @ for(int a=0;a<=listWidget->count();++a)
    listWidget->removeItemWidget(listWidget->item(a));@
    There are no errors, item just donr removes

    1 Reply Last reply
    0
    • S Offline
      S Offline
      steno
      wrote on last edited by
      #2

      Why don't you just use the clear function to remove all the items?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        Thank you, i just dont see it

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          In addition, your loop should probably terminate at "a < listWidget.count()", not "a <= listWidget.count()".

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            The code cannot work, as you remov items from the beginning. After processing half of the items your counter exceeds the count of the remaining items. Call remove on item(0), then the code should work.

            clear() is the more elegant solution, though :-)

            http://www.catb.org/~esr/faqs/smart-questions.html

            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