[Interest] A simple, changing list: QListWidget or QListView?

Alejandro Exojo aexojo at modpow.es
Mon Apr 8 15:17:43 CEST 2013


Hi.

I have to display a moderately simple list (6-8 rows at most, not
directly editable). I've done it quite simply with a class derived
form QListWidget, and a custom QListWidgetItem that creates new
widgets (one or two QLabels, nothing fancy), and places them in the
list with setItemWidget(). This works apparently fine, but when
changing the value of one of the labels in the widget, sometimes, and
only sometimes, the list displays pretty badly, and either shows one
row completely empty (because makes 0 the width of the elements
inside), or wants to leave one extra space for a phantom row.

The documentation for setItemWidget says "This function should only be
used to display static content in the place of a list widget item".
Well, the content is static in the sense that the user doesn't have to
edit it. Is an embedded application, and is just one click here or
there that changes the values in a quite limited way (e.g. no keyboard
input, no special editor widget, etc.).

The odd display bugs seem to tell me that I should be using the "full
blown" QListView and model/view classes, but still, QListWidget is
also based on these classes, so I have doubts that doing it on my own
is going to be much different. Seems a really simple use case.

Any advice?
Thank you.

-- 
Alejandro Exojo Piqueras

ModpoW, S.L.
Technova LaSalle | Sant Joan de la Salle 42 | 08022 Barcelona | www.modpow.es



More information about the Interest mailing list