Hi,

Only one default property is currently supported. Item works around this by 
having a single default property (data), that also assigns its values to either 
children or resources based on their type (e.g. when a Timer gets appended to 
the data property of Item, Item checks the type, and also appends to resources).

Regards,
Michael

On 11/01/2011, at 3:21 AM, ext [email protected] wrote:

> A related question; can you define several default properties for different 
> types? 
> 
> The Item seems to have e.g. a list<Item> children and a list<Object> resources
> that are both default, no? But when I try to define more than one default 
> property
> I get an error. 
> 
> Maybe this is another aspect of 
> http://bugreports.qt.nokia.com/browse/QTBUG-15127
> or maybe it's just something you can't do in pure QML?
> 
> 
> Cheers
> Mathias
> 
> 
> ________________________________________
> From: [email protected] 
> [[email protected]] on behalf of ext 
> Gregory Schlomoff [[email protected]]
> Sent: Monday, January 10, 2011 10:46 AM
> To: Attila Csipa
> Cc: [email protected]
> Subject: Re: [Qt-qml] Timer without animation ?
> 
> Hello,
> 
> The answer is yes.
> 
> One thing that QML developpers tend to forget easily is that nesting
> elements inside others is not a "native" feature of the language.
> Instead, it works through the default property mechanism.
> 
> Let's consider an example. When you write:
> 
> Rectangle {
>  Timer {...}
> }
> The QML engine actually interprets that as:
> Rectangle {
>  data: [
>   Timer {...}
>  ]
> }
> 
> But because "data" has been declared as the default property, you
> don't need to specify it. You just write your objects one inside the
> other.
> 
> "data" is a property of Item [1], and since all visual items inherit
> from Item, now you know why you can put a Timer inside any visual
> item. QtObject, on the other hand, has only one property: QString
> objectName. This is why you cannot put the timer inside it.
> 
> Now, if you want to put a Timer inside a QtObject, you at least two options :
> 
> === Option 1 : inside a dedicated property ===
> QtObject {
>  property Timer myTimer: Timer { ... }
> }
> 
> === Option 2 : inside a generic property ===
> QtObject {
>  property list<QtObject> data
>  data: [
>    Timer { id: myTimer; ... }
>  ]
> }
> 
> Etc...
> 
> The best solution would be to use the second case and to declare
> "data" as the default property, so that you actually get the same
> syntaxt as with visual items, but for some reason it's not working. I
> guess if you create your own QObject wrapper in C++ and declare the
> default property there, it will be ok.
> 
> Cheers,
> 
> Greg
> 
> [1] see: http://doc.qt.nokia.com/main-snapshot/qml-item.html
> On Mon, Jan 10, 2011 at 5:05 PM, Attila Csipa <[email protected]> wrote:
>> 
>> Is it possible to have a Timer without having a visual item that brings in 
>> the animation timer ? Think
>> 
>> QtObject {
>>    Component.onCompleted: console.log("hello world");
>>    Timer {
>>             interval: 500; running: true; repeat: true;
>>             onTriggered: console.log("tick");
>>    }
>> }
>> 
>> This gives somewhat cryptic Component is not ready error, but does work if I 
>> replace QtObject with Item. Now, you will be asking well, why don't you just 
>> use Item, and the answer is that it feels a bit weird - I'm experimenting 
>> with GUIless QML (think custom structured QtObject creation, textual UIs, 
>> etc).
>> 
>> Best regards,
>> Attila
>> 
>> _______________________________________________
>> Qt-qml mailing list
>> [email protected]
>> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
>> 
> _______________________________________________
> Qt-qml mailing list
> [email protected]
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
> _______________________________________________
> Qt-qml mailing list
> [email protected]
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to