You need to write a contact list for the messenger. To do this, I try to design everything correctly for convenient operation and simple expansion.

At the moment there are several models of entities with representations for them. Let's call them User , Chat , Group (everyone has a common parent AbstractModel ) and ***View for each of them.
It is necessary to draw this list beautifully for some criteria:

  • Only groups
  • Only contacts
  • Correspondence (chats and contacts)

I know that at this stage everything is already bad, but the project is commercial and I cannot rewrite everything.

So, at the moment the best thing I thought of is to make a model inherited from QAbstractListModel and contain all elements in it ( QVector<AbstractModel> ), bind this model to QListView and create a QSortFilterProxyModel , which will be responsible for displaying by criteria + sorting.

But in this approach I came across one very significant problem that I cannot solve for several days already: each element has its own specific idea and I don’t know how to properly install it. QListView not able to expand lines as needed.

The funny thing is that in QListWidget these problems are not in principle, but you cannot attach your models to it ...

Maybe I'm wrong somewhere? I would appreciate if you specify

  • "expand strings as needed." - Does QItemDelegate not help with this? - Madisson
  • @Madisson if I use QItemDelegate , I’ll have to use createEditor , and how to install the widget for the view (and not just for editing) so I don’t know - sm4ll_3gg
  • 2
    At forum.qt.io I was prompted by one interesting solution. Not exactly as I wanted, but I will leave it here: forum.qt.io/topic/85193/… - sm4ll_3gg

0