I am making a complete startup in BlackBerry 10 development. I am developing an app that should take user input from the text box and find that there is a word event in the text file. I'm using the trigger () signal of ActionItem to start the search. However, when I try to bring the input of the user from within the slot, it always returns an empty string ''. What mistake I am doing I
thanks in advance
Here is the code to make: ..
main.qml
TextField {objectname: "Anagram" hintText: "Enter anagram to search" verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center input { SubmitKey.Done}}
application.cpp
verbs * main = root-> SearchBild & Battle; Action Item * & gt; ("Search"); Bool res1 = QObject :: connect (main, signal (trigger), this, slot (onsearch ())); Zero ApplicationUI :: onSearch () {qDebug () & lt; & Lt; "Slots active"; QmlDocument * qml = QmlDocument :: create ("asset: ///main.qml"). Spinach (this); Sarpane * Root = qml- & gt; CreateRootObject & lt; Absetpen & gt; (); Application: Example () - & gt; SetScene (root); Textfield * Query = Root- & gt; Finding & Lt; Textfield * & gt; ("Anagram"); // From bottom to bottom STRING '' QString search = query- & gt; Text (); itemprop = "text"> intro
slot onsearch
/ Code> is called that you are effectively creating an extra UI, which is actually unrelated to the one emitting the signal.
Since there is no default setting for text Anagram
, which you have concluded is correct; It will always produce an empty string since the area will always be made fresh.
solution
You will need to use the associated with the root
current UI (that user has inputted for the data), Instead of creating a new one
Assuming that you have declared Optional solution You access the loaded current You can also view (return root as a data-member of ApplicationUI , below what you expected (and want) Must do
zero ApplicationUI :: onSearch () {qDebug (). & Lt; & Lt; "Slots active"; Textfield * Query = Root- & gt; Finding & Lt; Textfield * & gt; ("Anagram"); QString search = query-> Text (); // ...}
root
in your snippet) by returning to the view ()
at pointer-to AbstractPane
on the application. : Example ()
:
Sarpan * current_scene = Application :: Example () -> View (); QString search = current_assine- & gt; Find Chilled & lt; TextField * & gt; ("Anagrams") - & gt; Text ();
No comments:
Post a Comment