I've created an implementation of the QAbstractListModel class in Qt Jambi 4.4 and am finding that using the model with a QListView results in nothing being displayed, however using the model with a QTableView displays the data correctly.
I'm experienced with C# but have only been using Qt Jambi for a couple of days now.
Below is my implementation of QAbstractListModel
public class FooListModel extends QAbstractListModel
{
private List<Foo> _data = new Vector<Foo>();
public FooListModel(List<Foo> data)
{
if (data == null)
{
return;
}
for (Foo foo : data)
{
_data.add(Foo);
}
reset();
}
public Object data(QModelIndex index, int role)
{
if (index.row() < 0 || index.row() >= _data.size())
{
return new QVariant();
}
Foo foo = _data.get(index.row());
if (foo == null)
{
return new QVariant();
}
return foo;
}
public int rowCount(QModelIndex parent)
{
return _data.size();
}
}
And here is how I set the model:
Foo foo = new Foo();
foo.setName("Foo!");
List<Foo> data = new Vector<Foo>();
data.add(foo);
FooListModel fooListModel = new FooListModel(data);
ui.fooListView.setModel(fooListModel);
ui.fooTableView.setModel(fooListModel);
Can anyone see what I'm doing wrong? I'd like to think it was a problem with my implementation because, as everyone says, select ain't broken!
Thanks for your time...