PyQt: QListView how to retrieve selected items?
Diez B. Roggisch
deets at nospam.web.de
Thu Feb 2 14:31:39 EST 2006
Flavio schrieb:
> Hi,
>
> I have a QListview widget that allows me to store a bunch of strings in
> it. This strings can be visualized, sorted, selected, etc.
>
> My Problem is that I cant find a way to get the user selected items
> back from it! I looked over the Qt documentation many times over but
> there is no method to that end.
>
> Any PyQt guru lurking around?
>
> should I try some other list widget, that has a "getSelected()"method?
> Is there one?
QListViewItem.isSelected()? You have to loop over the items to get the
ones selected.
Additionally, you might want to register for the
selectionChanged
signal. In Single-selection-mode there even is a overloaded version that
directly gives you the selected item.
And all of this can be found within 20 seconds in the great Qt-Docs.
Especially easy with the included QAssistant, a help-browser with
indexing and whatever...
Diez
More information about the Python-list
mailing list