How to debug: QAbstractTableModel subclass does not call flags()

I have a subclass of QAbstractTableModel which correctly calls data() and setData() but does not call flags().

Since it is correctly calling data() & setData(), I presume the initialization should be correct for the QAbstractTableModel as a parent class of the object. I’m also using PyCharm, and it correctly shows an icon indicating which methods are being overridden.

I have another class with QAbstractTableModel as a parent class and it operates correctly. Debugging print statements flood the console in moving the mouse. So I presume something is up with the implementation of the other class.

The primary difference between the working/non-working classes is that the non-working class has multiple inheritance, defined as class A( B, QAbstractTableModel )

The other class has single inheritance as class C( QAbstractTableModel )

Since PyCharm seems to parse and identify overridden methods correctly and since the data() and setData() are working, I presume that initialization of the parent classes of A are correct.

Any suggestions on debugging would be appreciated.

Best regards,

I’m guessing that a QLineEdit, accessing a class derived from QAbstractTableModel, using the QDataWidgetMapper, does not call the flags() method of the QAbstractTableModel.

The doc Model/View Tutorial | Qt Widgets 5.15.3 describes standard widgets and MV widgets and depicts under section 1.3 Overview of the Model/View Widgets.

It goes on to describe adapters, section 1.4 Using Adapters between Forms and Models, and references example widget QLineEdit.

I’m going to speculate that the QDataWidgetMapper will fetch and set data managed under QAbstractItemModel and the associated derived classes, eg QAbstractTableModel which I’m using, however the QDataWidgetMapper will not be making flags() calls to set the params of widgets, such as QLineEdit.

Any other thoughts?


1 Like

Hi @Otto_Hirr welcome to the forum & apologies for the delay in responding, I misses this when it first came in.

I think you’ve hit the nail on the head re: QLineEdit. The flags() are only really relevant to the model views which are designed to handle them. The flags are requested from the model when required by the view, but standard widgets have no mechanism to do this. The QDataWidgetMapper would be the place to look for this perhaps, as that does know about the flags mechanism and could feasibly apply changes to the widget (e.g. checkbox tristate).

Which flags were you hoping to apply to the QLineEdit, perhaps we can work something out.