Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.1
-
None
-
Qt trunk 25/10/2010, Mac OS X 10.6.4
Description
This may be a documentation issue or possibly unintended behaviour.
When accessing 'item properties' on a qml declared object, QDeclarativeProperty doesn't work for the case where an engine is passed in the constructor, or via the static QDeclarativeProperty::write.
With the following qml components in the import path :
TypeA.qml
import Qt 4.7
TypeA {
property string someString
}
TypeB.qml
import Qt 4.7
TypeB {
property TypeA myTypeA
}
assuming from c++ that components of TypeA and TypeB are created successfully using QDeclarativeComponent::create() as.
QObject* myTypeA = component.create();
QObject* myTypeB = component.create();
trying to assign myTypeA to the qml's property in myTypeB fails :
QDeclarativeProperty::write(myTypeB, "myTypeA", QVariant::fromValue(myTypeA), engine);
whereas using a context succeeds :
QDeclarativeProperty::write(myTypeB, "myTypeA", QVariant::fromValue(myTypeA), engine->rootContext());
It seems as if qdeclarativeproperty.cpp:950 obtains the enginePriv only from an assigned context, but does not check if an engine is also assigned, and so type coercion fails. As metaobject checking is only used when assigning QObject* derived variants, it looks like it's the only case that fails, i.e. value based variants and lists (via QDeclarativeListReference) work when passing an engine.