PDA

View Full Version : QListWidget - signal when items are added/removed



Andrej08
18th January 2011, 16:10
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.

wysota
19th January 2011, 02:13
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).