Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 1 KB

README.md

File metadata and controls

18 lines (12 loc) · 1 KB

PyQt5 QListView

This example shows how you can use a PyQt5 QListView to display a list.

PyQt5 QListView

It simply shows a static list of strings. Technically, the data is managed by Qt's QStringListModel. The important steps of the code are:

model = QStringListModel(["An element", "Another element", "Yay! Another one."])
view = QListView()
view.setModel(model)
view.show()

This is very similar to the previous example, where we displayed a tree view of files. The reason for this similarity is that both examples use Qt's Model/View framework. As an exercise for yourself, you might want to try using QListView instead of QTreeView in the previous example.

To run this example, please follow the instructions in the README of this repository.