私はQMLアプリケーション(blackberry 10)に取り組んでおり、次のようなQMLファイルを持っています:
import bb.cascades 1.0
Page {
content: Container {
id: containerID
Button {
id: button1
text: "text"
onClicked: {
}
}
Label {
id: label1
text: "text"
}
}
}
label1
今、私は私のC ++コードでにアクセスしたいので、次のコードがあります:
#include "app.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
using namespace bb::cascades;
App::App()
{
QmlDocument *qml = QmlDocument::create("main.qml");
//-- setContextProperty expose C++ object in QML as an variable
//-- uncomment next line to introduce 'this' object to QML name space as an 'app' variable
//qml->setContextProperty("app", this);
AbstractPane *root = qml->createRootNode<AbstractPane>();
QObject *labelTest = root->findChild<QObject*>("label1");
if (labelTest)
labelTest->setProperty("text", "yes!!");
Application::setScene(root);
}
アプリを実行しましたが、ラベルのテキストは変わりません。
なにが問題ですか?