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. Clearing a QListWidget from private slot
Forum Updated to NodeBB v4.3 + New Features

Clearing a QListWidget from private slot

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.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.
  • W Offline
    W Offline
    WhatIf
    wrote on last edited by WhatIf
    #1

    Hi,

    I'm trying to clear the content of QListWidget using the following code:

    ui->displayChildLWidget->clear();
    

    as first line in a private slot and it's not working, before the code that adds items to the QListWidget. It simply adds to the content of QListWidget from the previous runs. For example, if Mike was displayed inside displayChildLWidget in first run, if run again to display Robert, it displays Mike followed by Robert instead of just Robert. If run again to display Joe, it dispalys

    Mike
    Mike
    Robert
    Mike
    Robert
    Joe

    The same code QListWidget->clear() works fine inside other functions. Does QListWidget inside private slot have to be handled differently?

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

      Hi
      are you sure the slot is called?
      insert qDebug() << "in slot" ;
      to be sure.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        WhatIf
        wrote on last edited by
        #3

        The slot role is to display info and part of it is the QListWidget. The info is displayed so I have no doubt that the slot is called. The issue is only in the QListWidget; it adds to the info from the previous search.

        If in the first Seach, I search for person A who has child "Mike", it displays Mike. If I search for person B who has child "Ryan", it displays Mike followed by Ryan instead of just Ryan

        mrjjM 1 Reply Last reply
        0
        • W WhatIf

          The slot role is to display info and part of it is the QListWidget. The info is displayed so I have no doubt that the slot is called. The issue is only in the QListWidget; it adds to the info from the previous search.

          If in the first Seach, I search for person A who has child "Mike", it displays Mike. If I search for person B who has child "Ryan", it displays Mike followed by Ryan instead of just Ryan

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @WhatIf said:

          Hmm, i cannot reproduce it.
          it clear the list even if slot is private

          https://www.dropbox.com/s/36yq306z31agvov/clearlist.zip?dl=0

          so I think you have some other bug :)

          1 Reply Last reply
          0
          • W Offline
            W Offline
            WhatIf
            wrote on last edited by
            #5

            Found it :)

            The QListWidget was used somewhere else......my mistake.

            Thanks!

            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