[Development] QtWidgets Item / Model / View: tree model examples

apoenitz apoenitz at t-online.de
Tue Nov 21 20:10:40 CET 2023


On Tue, Nov 21, 2023 at 05:00:43PM +0100, André Somers wrote:
> > If not, could we start propagating QTreeWidgetItem or QStandardItem in
> > those examples instead to avoid reinventing?
> 
> No, please. I would suggest to instead deprecate these classes, at minimum
> the Widgets (QListWidget, QTableWidget and QTreeWidget) and their *Item
> classes. These classes lead to horrible code in practice. Propagating their
> use in examples is going backwards.

I agree with the assessment below but not with the demand to deprecate these
classes.

QStandardItemModel clumsy to use? When it needs to update/change - sure.
Wrong name? Perhaps. Should people use a "real" model? Sure.

But: /Any/ deprecation hurts and leave people and projects behind. Not
everyone has the means to update at will. And if someone is happy with 
QStandardItemModel for the task at hand then forcefully destroying this
is a bear service.

> QStandardItemModel is a complete misnomer, it is anything but standard.
> Instead, it should be understood as something like QPrototypeItemModel or
> something: suitable to use to play around with or whip up a quick test or
> something, but not for production code. The standard way of working should
> be writing a real model based around your own application specific data
> structures.

Make it clear in the docs that this is at best for prototyping or static model,
and make it clear that a "real" model will be better almost always. And maybe
provide a means to create simple tree models without having to think of
invalid grandparents of model indices.

> Cheers,
> 
> André

Dito.



More information about the Development mailing list