Skip to content
Advertisement

Adding items to QlistView

I’m using pyqt4 with python 2.7 and I have a list view widget that I can’t add items to it

JavaScript

As you guys can see i used

JavaScript

But it gave me an error that is talking about arguments and data types:

JavaScript

Also, is it right to use ListView here or I should use listwidget?

In general, what is the difference between both !!

Advertisement

Answer

QListWidget is a class of higher level that makes the developer can handle it easily, for example QListWidget has a model of type QStantandardItemModel that can not be accessed, in addition to built the QListWidgetItem to handle the data, as you have seen is simple add data through functions like addItem() or addItems().

On the other hand QListView, from which QListWidget inherits, is of lower level, where you can customize many things, using custom models, etc.

You can use both:

QListView

JavaScript

QListWidget

JavaScript
User contributions licensed under: CC BY-SA
11 People found this is helpful
Advertisement