Привет всем.
Пишу проект на qml. Столкнулся с такой проблемой, что событие onClicked привязывается не к конкретному "слою", а ко всему parent для этого слоя.
Теперь конкретнее:
import QtQuick 1.0
Rectangle {
id: background
width: 640
height: 480
color: "Transparent"
Rectangle {
x: parent.x + 10
y: parent.y + 10
width: parent.width - 20
height: parent.height -20
color: "#5F5F5F"
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
}
import QtQuick 1.0
Rectangle {
id: background
width: 640
height: 480
color: "Transparent"
Rectangle {
x: parent.x + 10
y: parent.y + 10
width: parent.width - 20
height: parent.height -20
color: "#5F5F5F"
Rectangle {
x: parent.x
y: parent.y
width: parent.width - 100
height: parent.height - 50
}
Text {
text: parent.x
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
}
Проблему решил так:
На каждый из rectangle повесил свое событие для мыши и все. Естественно, у верхнего слоя, оно пустое. onclick: {}
Форум Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)