[Interest] C++/QML integration with QAbstractTableModel and QML Repeater
Christoffer Holmstedt
christoffer.holmstedt at gmail.com
Mon Sep 15 15:34:06 CEST 2014
Hi
Just started to learn how Qt works with QtQuick (Qt 5.3.1). I have
successfully tried different examples available in the docs but there is
one thing I can't get my head around and that is when subclassing
QAbstractTableModel (QAbstractListModel works just fine).
Code available on github [1] (run qmlscene for expected result).
What I'm trying to achieve is a simple 2D grid of squares. With a QList<T>
and QAbstractListModel the Repeater it just works, but when I changed the
data structure to a std::vector<std::vector<T>>> and QAbstractTableModel I
only get the first element in the outer vector. Simple debug output from my
BoardModel::data member function suggests that index.column() is always 0
when used with the QML Repeater view.
1) Is the assumption above correct that the Repeater view only increases
the index.row() value when requesting data?
2) Is this expected behaviour for all QML views? (even the tableview
requires the columns to be specific roles afaik).
3) My best bet now is that it's in the front-end/QML code I need to change
to another view type/element to properly request data in all rows AND
columns. How is this best done?
Any suggestion pointing me in the right direction is greatly appreciated.
[1] https://github.com/christofferholmstedt/MineSweeper
Regards
--
Christoffer Holmstedt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140915/efbd5a97/attachment.html>
More information about the Interest
mailing list