I'm a complete beginner in Blackberry 10 development. I'm developing an app that should take user input from a text box and search if there is an occurrence of the word in a text file. I'm using the triggered() signal of ActionItem to invoke the search. However, when I try to fetch the user input from within the slot it always returns an empty string ''. What mistake I'm I making.
Thank you in advance.
Here is the code:
main.qml
TextField {
objectName: "anagram"
hintText: "Enter anagram to search"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
input {
submitKey: SubmitKey.Done
}
}
application.cpp
ActionItem *main = root->findChild<ActionItem*>("search");
bool res1 = QObject::connect(main, SIGNAL(triggered()), this, SLOT(onSearch()));
void ApplicationUI::onSearch()
{
qDebug() << "slot activated";
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(root);
TextField* query = root->findChild<TextField*>("anagram");
//THE STRING BELOW ALWAYS RETURNS ''
QString search = query->text();
...