Results 1 to 2 of 2

Thread: QListWidget - signal when items are added/removed

  1. #1
    Join Date
    Jan 2011
    Posts
    1
    Qt products
    Qt4

    Default Re: QListWidget - signal when items are added/removed

    Is there any signal I can use when an item is added or removed from a QListWidget? I need to resize the widget to fit its contents, but I can't override the addItem method when I subclass QListWidget because it's marked final. (This is using the QtD wrapper library, but it shouldn't be too different from the way Qt works).

    Oh, nevermind. All I had to do was override the paintEvent method, it gets called automatically when items are added/removed.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListWidget - signal when items are added/removed

    Quote Originally Posted by Andrej08 View Post
    Oh, nevermind. All I had to do was override the paintEvent method, it gets called automatically when items are added/removed.
    And in a couple of other places which makes it a bad candidate for doing anything other than painting.

    Access the widget's model and connect to one of its signals (like rowsInserted/rowsRemoved).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 28th October 2010, 22:36
  2. Drop indicator not removed after dropEvent() in QListWidget
    By Daniel Dekkers in forum Qt Programming
    Replies: 0
    Last Post: 9th April 2010, 14:49
  3. QListWidget cannot handle too many items
    By mr.hichem in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 23:00
  4. Associate userData to items added to a QListWidget.
    By schall_l in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2009, 12:24
  5. Getting all items of a QListWidget
    By Codepoet in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2006, 22:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.