伙计们,我正在 BlackBerry 10 中开发基本应用程序,我想获取 TextField(在 cpp 中)中的文本。我正在尝试为此找到方法,但没有找到正确的方法。所以任何人都可以告诉我如何从 cpp 中的 TextField 中获取值(而不是在 qml 中)???
最佳答案
好吧,您需要做的第一件事是将您的 QML TextField 公开给 C++。这是通过对象名称属性 ala 完成的:
TextField {
objectName: "myTextField"
...
}
接下来,从你的 C++ 中找到这个 child :
QmlDocument *qml = QmlDocument::create("asset:///my.qml");
Container *root = qml->createRootObject<bb::cascades::Container>(); //or whatever the root control is
TextField *textField = root->findChild<TextField*>("myTextField");
从那时起,只需使用 textField->text()。
关于c++ - BlackBerry 10开发-TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18457776/