[Qt-qml] QML Query

Dumb Acnt dumb.acnt at gmail.com
Tue Jan 25 10:02:35 CET 2011


Hi All,

I had a quick QML question that I wanted to bounce off of you all.

I was looking at the minehunt [*
http://doc.qt.nokia.com/latest/demos-declarative-minehunt.html*] Qt
declarative example and am able to see good application of this in my
application.

However I have a slight deviation from the data structure point of view
here. I would like to make the TileData class in the minehunt example to be
a composition of other QObject derived classes which will also expose their
properties to the QML view.

However I have failed to do so as once a class is make to derive from
QObject it can no longer be copied and hence can not have a READ Q_PROPERTY
for the QML view to come and read it. Unless I am assuming we make it a
pointer. However this as well does not seem to work for me. Here is what I
am thinking of about extending the TileData class.

class TileType : public QObject
{
    Q_PROPERTY (int corners READ corners NOTIFY cornersChanged)
...
};
class TileData : public QObject
{
    Q_PROPERTY Q_PROPERTY> (TileType tileType READ tileType NOTIFY
tileTypeChanged)
    TileType tileType () const { return mTileType; }
...
    TileType mTileType;
};

What do I need to do in the above code so that in the QML file I can do
something like this: *modelData.tileType.corners
*
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110125/38217270/attachment.html 


More information about the Qt-qml mailing list