代码:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.4
import QuickOSGEarth 1.0
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Button{
id: createCylinderManipulatorButton
text: qsTr("Load")
z:10
Component.onCompleted: {
var keys = Object.keys(createCylinderManipulatorButton);//对象的所有属性
for(var i = 0; i < keys.length; i++) {
var key = keys[i];
// prints all properties, signals, functions from object
console.log(key + ' : ' + createCylinderManipulatorButton[key]);
if (key === "x") {
createCylinderManipulatorButton[key] = 100;
}
}
}
}
}
结果:
qml: objectName :
qml: parent : QQuickRootItem(0x5efcbf8)
qml: data : [object Object]
qml: resources : [object Object]
qml: children : [object Object]
qml: x : 0
qml: y : 0
qml: z : 10
qml: width : 100
qml: height : 40
qml: opacity : 1
qml: enabled : true
qml: visible : true
qml: visibleChildren : [object Object]
qml: states : [object Object]
qml: transitions : [object Object]
qml: state :
qml: childrenRect : QRectF(0, 0, 100, 40)
qml: anchors : QQuickAnchors(0xb06ffc8)
qml: left : QVariant(QQuickAnchorLine)
qml: right : QVariant(QQuickAnchorLine)
qml: horizontalCenter : QVariant(QQuickAnchorLine)
qml: top : QVariant(QQuickAnchorLine)
qml: bottom : QVariant(QQuickAnchorLine)
qml: verticalCenter : QVariant(QQuickAnchorLine)
qml: baseline : QVariant(QQuickAnchorLine)
qml: baselineOffset : 6
qml: clip : false
qml: focus : false
qml: activeFoc