Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use a QListWidget over a QListView?

Tags:

qt

From what I understand, QListWidget is built on QListView, and implements a "traditional" list widget, without any model/view concept.

Is there any situation where QListWidget should be preferred over QListView, or is QListView always a better answer once the model/view concept is understood ?

like image 684
MickaëlG Avatar asked Feb 27 '16 21:02

MickaëlG


2 Answers

QListWidget is easier to use, even once you understood how models work. It can be handy to use in dialogs where a strict MVC separation is not that much of a concern.

like image 78
Georg Schölly Avatar answered Sep 21 '22 09:09

Georg Schölly


QListView is harder to understand, but far more extensible. For example, by implementing methods on it like canFetchMore and fetchMore on the model, you can create lists that gather more data as you scroll.

QListWidget is a narrow implementation of a QListView. It's perfect for prototyping and any situation where you might add and subtract small amounts of data to/from the list.

If your app isn't dependent on the list as its main element, you can probably get away with a QListWidget. If your core functionality comes from the list, you're better off tailoring a QListView to your needs.

like image 40
M. Davis Avatar answered Sep 19 '22 09:09

M. Davis