Здравствуйте. Произошла проблема с отображение данных с C++ в qml. Есть 2-ва класса: BaseBlock и его наследник Block.
- BaseBlock
class BaseBlock : public QObject
{
Q_OBJECT
Q_PROPERTY(int row READ GetRow NOTIFY rowChanged)
Q_PROPERTY(int column READ GetColumn NOTIFY columnChanged)
Q_PROPERTY(int imgSize READ GetImgSize CONSTANT)
Q_PROPERTY(QString imgAddress READ GetImgAddress CONSTANT)
public:
explicit BaseBlock(QObject *parent = 0);
explicit BaseBlock(int row, int column, QObject *parent = 0);
- Block
class Block : public BaseBlock
{
public:
Block();
Block(int row, int column, bool isTraversable, BLOCK_TYPE type);
И кусок кода, который отображает данных в qml-файлах
Q_PROPERTY(QQmlListProperty<BaseBlock> blocks READ GetBlocks NOTIFY block_Changed)
...
QList<BaseBlock*> _tiles;
...
QQmlListProperty<BaseBlock> GameBoard::GetBlocks() {
return QQmlListProperty<BaseBlock> (static_cast<QObject*>(this), _tiles);
}
qmlRegisterType<BaseBlock>("org.my.project", 1, 0, "BaseBlock");
QMetaProperty::read: Unable to handle unregistered datatype 'QQmlListProperty<Block>' for property 'GameBoard::blocks'