Skip to content

Instantly share code, notes, and snippets.

@brianthelion
Created December 17, 2016 14:53
Show Gist options
  • Save brianthelion/8e79f304fc509ab873575670f73dd635 to your computer and use it in GitHub Desktop.
Save brianthelion/8e79f304fc509ab873575670f73dd635 to your computer and use it in GitHub Desktop.
Strange behavior with childrenRect in which the onChildrenRectChanged signal doesn't always fire.
import QtQuick 2.5
import QtQuick.Controls 1.4
Item {
width: 800
height: 600
property string src: "import QtQuick 2.5; Rectangle{ width: 50; height: 50; color: \"red\"}"
Item {
id: a_container
x: 0
y: 100
width: 100
height: 100
property string name: "A"
onChildrenRectChanged: {
console.log(name)
}
}
Item {
id: b_container
x: 300
y: 100
width: 100
height: 100
property string name: "B"
onChildrenRectChanged: {
console.log(name)
}
property real _x: childrenRect.x // <-- CRITICAL LINE
}
Button {
x: 0
text: "A"
onClicked: {
Qt.createQmlObject(src, a_container)
}
}
Button {
x: 300
text: "B"
onClicked: {
Qt.createQmlObject(src, b_container)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment