0

I'm currently working on a Qt Quick application in which there is a TableView showing data from a backend model written in C++ (it is a custom model derived from QAbstractListModel).

I want to have to possibility to set which rows can be selected by the user, so I thought to extend the custom model by overriding the function:

Qt::ItemFlags flags(const QModelIndex &index) const

The change I made has no effect on the application and by debugging I noticed that the flags function is never called by anyone (tried both using a breakpoint and printing on console).

I tried several things (even changing the base model from QAbstractListModel to QAbstractTableModel) but didn't figure out why it is not working.

At the end I tried to launch an official example (Qt Quick TableView examples - Conway’s Game of Life) provided by Qt Creator but it has the same behavior (flags function overridden but never called).

How is that function supposed to work?

I'm using Qt Creator 4.10 with Qt 5.13.1 MSVC2015 (64 bit).

Thanks!

Brutus
  • 790
  • 3
  • 10
  • 27
  • 2
    As far as I know, the QML views do not use the flags() function, unlike the Qt Widgets delegates (QStyledItemDelegate, QItemDelegate) that do use them. – eyllanesc Jan 22 '20 at 17:11
  • @eyllanesc thanks, that would explain the behavior I'm observing! How did you know? I didn't find anything in the documentation, do you have any reference or hint about where to start looking? – Brutus Jan 23 '20 at 09:33

0 Answers0