QListView does not display model data

87 Views Asked by At

I have a dialog with several widgets, including two list views, say lv1 and lv2.

For each QListView, the class for the dialog has a private variable that is a pointer to the associated data model. Say these variables are called m1 and m2:

MyListModel* m1;
MyListModel* m2;

The class MyListModel for these two associated data models inherits from QAbstractListModel, and redefines methods data and rowCount. Stepping in the debugger shows that these methods are called and return the expected values.

The constructor for the dialog includes the following four instructions :

m1 = new MyListModel(...);
m2 = new MyListModel(...);
ui->lv1->setModel(m1);
ui->lv2->setModel(m2);

Nothing is displayed in the list views when the dialog opens (other widgets are properly filled, though) .

What could be wrong?

I tried setting a QStringListModel as a model for one of the list view. Again, the list view displayed no contents.

What could be wrong?

0

There are 0 best solutions below