Hi Charley,

On 27/11/2010, at 11:45 AM, ext Charley Bay wrote:

> I'm implementing "attached properties" on my custom C++ type (exposed to 
> QML), and am unsure about the "proper" use model:
> 
> <http://doc.qt.nokia.com/4.7/qml-extending.html>
> 
> For example, I did:
> 
> (a) Implement C++ class MyAttachedProperties, derived from QObject
> 
> (b) Implement static function and QML_DECLARE_TYPEINFO on C++ 
> MyClassWithAttachedProperties so QML triggers instantiation of the attached 
> properties object.
> 
> The above seems to work fine.  My questions:
> 
> (1) Logically, should the "state" for MyAttachedProperties simply reside 
> within the QObject meta-object system (e.g., through the QObject (base) 
> "property()/setProperty()")?  Or, can I have my own "state" in data members 
> for MyAttachedProperties that I "expose" as properties, or explicitly set as 
> properties within the QObject (base) meta-object?
> 
> (2) In the event I have application-specific types/state in 
> MyAttachedProperties, what "synchronization hooks" are assumed to be used to 
> expose that state to QML elements?  (For example, to translate 
> application-specific type state to QVariant values useful to QML elements?)

The docs on attached properties could probably be expanded, if you have any 
suggestions. Can you clarify what you mean here? Are you asking whether it's 
worth exposing data as actual properties for an attached object? And what do 
you mean by 'assumed' synchronization hooks?


> (3) Are there examples showing use of "attached properties" other than what 
> is mentioned in the "Birthday" example in the Qt 4.7 docs?  (I didn't find 
> anything else, or anything else on the web ... ?)  Specifically, I'd like to 
> see examples of "recursive grouped" attached properties state like the docs 
> mention is possible, such as binding a value within QML like "a.b.c.d.e: 42"
> 

The QGraphicsLayouts examples use attached properties, but they probably don't 
expand on anything beyond what is in the birthday example:

http://doc.qt.nokia.com/4.7-snapshot/declarative-cppextensions-qgraphicslayouts-qgraphicsgridlayout.html
http://doc.qt.nokia.com/4.7-snapshot/declarative-cppextensions-qgraphicslayouts-qgraphicslinearlayout.html

In terms of recursively accessing properties, I assume if Birthday.rsvp was not 
a date value, but instead was a  custom 'Rsvp' object containing a 'date' 
value, then it could be accessed as "Birthday.rsvp.date".


regards,

Bea


_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to