thanks, franz
ya, read the blog more carefully this time, was looking for how the controls defined with qml can be linked to the functions,
for example, on a page, with qml,. could create a fancy button on it, but when I click on it how to trigger the event handler.
seems the snippet below answered the question.
---------------------------------
import Qt 4.6
Rectangle {
id: container
property string label
signal clicked
radius: 5; border.color: "black"
color: mouse.pressed ? "steelblue" : "lightsteelblue"
gradient: Gradient {
GradientStop { position: mouse.pressed ? 1.0 : 0.0; color: "steelblue" }
GradientStop { position: mouse.pressed ? 0.0 : 1.0; color: "lightsteelblue" }
}
MouseRegion { id: mouse; anchors.fill: parent; onClicked: container.clicked() }
Text { anchors.fill: parent; text: container.label; anchors.centerIn: parent }
}
QmlComponent component(qmlEngine, "Button.qml");
QObject *button = component.create();
button->setProperty("label", tr("Press Me!"));
connect(button, SIGNAL(clicked()), this, SIGNAL(buttonClicked()));
Bookmarks