From 271c790e020b82be88e421611bef169334ea0a4f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Jan 2011 10:49:13 +1000 Subject: Consistent Docs Example contradicted later docs. Fixed example. Task-number: QTBUG-16596 --- doc/src/snippets/declarative/codingconventions/photo.qml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/src/snippets/declarative/codingconventions/photo.qml b/doc/src/snippets/declarative/codingconventions/photo.qml index 61e7eb7..78c5068 100644 --- a/doc/src/snippets/declarative/codingconventions/photo.qml +++ b/doc/src/snippets/declarative/codingconventions/photo.qml @@ -49,12 +49,20 @@ Rectangle { signal clicked // signal declarations - function doSomething(x) { // javascript functions + function doSomething(x) // javascript functions + { return x + photoImage.width } - x: 20; y: 20; width: 200; height: 150 // object properties - color: "gray" // try to group related properties together + color: "gray" // object properties + x: 20; y: 20; height: 150 // try to group related properties together + width: { // large bindings + if(photoImage.width > 200){ + photoImage.width; + }else{ + 200; + } + } Rectangle { // child objects id: border -- cgit v0.12 From 3526db3b8832c357b368014e6c8ebab63d4071da Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 13 Jan 2011 14:40:31 +1000 Subject: Don't crash Qt Creator when debugging an object alias Task-number: QTBUG-16131 --- src/declarative/qml/qdeclarativeproperty.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index e7dae98..8210314 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -665,7 +665,7 @@ QDeclarativePropertyPrivate::binding(QObject *object, int coreIndex, int valueTy static_cast(metaObjectForProperty(object->metaObject(), coreIndex)); QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1; - if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) + if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex) || aCoreIndex == -1) return 0; // This will either be a value type sub-reference or an alias to a value-type sub-reference not both -- cgit v0.12 From 72942b7dab497b656fad8eeb6240fe310a31be29 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 13 Jan 2011 14:59:30 +1000 Subject: Add an autotest for QVariant method params --- .../auto/declarative/qdeclarativeecmascript/testtypes.h | 2 ++ .../tst_qdeclarativeecmascript.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 7724335..6c6ad1f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -624,6 +624,8 @@ public: Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; } + Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; } + private: friend class MyInvokableBaseObject; void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 90006a9..034adf7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1786,6 +1786,22 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.invoked(), -3); QCOMPARE(o.actuals().count(), 1); QCOMPARE(o.actuals().at(0), QVariant(9)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QVariant(9)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(9)); + QCOMPARE(o.actuals().at(1), QVariant()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QVariant(\"Hello\", \"World\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(QString("Hello"))); + QCOMPARE(o.actuals().at(1), QVariant(QString("World"))); } // QTBUG-13047 (check that you can pass registered object types as args) -- cgit v0.12 From 56bc3e3a40ab694ca5e1b2887c5887e8aa05de04 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Jan 2011 15:11:33 +1000 Subject: Document level of support for QGraphicsObject properties In the context of QML, they are not officially supported as public API unless otherwise documented in QDeclarativeItem. This commit mentions that somewhere. Task-number: QTBUG-15797 Reviewed-by: Martin Jones --- doc/src/declarative/qtbinding.qdoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 4213f66..b1de3e4 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -235,6 +235,10 @@ defined by C++ classes; in fact, many of the core \l {QML Elements} are implemen C++ classes. When you create a QML object using one of these elements, you are simply creating an instance of a QObject-based C++ class and setting its properties. +To create a visual item that fits in with the Qt Quick elements, base your class off \l QDeclarativeItem instead of QObject directly. +You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QDeclarativeItem because +it does not paint anything; you will need to clear this if your item is supposed to paint anything (as opposed to being solely for input handling or logical grouping). + For example, here is an \c ImageViewer class with an \c image URL property: \snippet doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h 0 @@ -249,6 +253,11 @@ Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlu \snippet doc/src/snippets/declarative/qtbinding/newelements/standalone.qml 0 + +It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem. +This is because the GraphicsView backend is an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. +To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarative item where possible as properties it inherits but doesn't document are classed as implementation details and may disappear. + Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is a displayable item. If the item is not displayable, it can simply inherit from QObject. -- cgit v0.12 From 7b8c7462dde454c25e92e401292e973da04f2189 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Jan 2011 15:17:47 +1000 Subject: Document centerIn and fill in the anchors docs Task-number: QTBUG-16467 --- doc/src/declarative/anchor-layout.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index f03d9ee..941acfe 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -78,6 +78,9 @@ Rectangle { id: rect3; x: 150; ... } \image edge4.png +There are also some convenience anchors. anchors.fill is a convenience that is the same as setting the left,right,top and bottom anchors +to the left,right,top and bottom of the target item. anchors.centerIn is another convenience anchor, and is the same as setting the verticalCenter +and horizontalCenter anchors to the verticalCenter and horizontalCenter of the target item. \section1 Anchor Margins and Offsets -- cgit v0.12 From b034416ab293a71fcedd744d503a30365b664049 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Jan 2011 16:21:58 +1000 Subject: Fix doc typo Tidy up that section a little, while I'm at it. --- doc/src/declarative/qtbinding.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index b1de3e4..03290aa 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -255,8 +255,8 @@ Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlu It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem. -This is because the GraphicsView backend is an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. -To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarative item where possible as properties it inherits but doesn't document are classed as implementation details and may disappear. +This is because the GraphicsView backend is intended to be an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. +To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarativeItem where possible. Properties QDeclarativeItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is a displayable item. If the item is not displayable, it can simply inherit from QObject. -- cgit v0.12