0

How to save the entered text in blackberry 10. I'm planning to save it to stackmob by saving it using the submit/send key of the keypad

TextField {
                            id: tfComment
                            hintText: qsTr("add comment")
                            inputMode: TextFieldInputMode.Text
                            input {
                                submitKey: SubmitKey.Submit
                                onSubmitted: {
                                }
                            }

What should i add on the submitkey and on the cpp?

kev
  • 155
  • 1
  • 11

2 Answers2

0

Within the onSubmitted slot, you should call a C++ invokable function, with text as parameter. Your C++ function should take a QVariant, which will contain the string typed by the user.

Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
0

You want to save it to cloud ? or just in local device ?

For local device you can use QSettings, its quite easy and useful.

For internet, you can pass entered data from QML to c++ by first exposing C++ object to QML. and then calling appropriate API with parameter.

You can expose C++ object to QML by following code

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
FileModel fileModel;
qml->setContextProperty("fileModel", &fileModel);

Now your QML code will be able to use fileModel instance by fileModel name and you can call its public slot method or Invokable method from QML

Kunal
  • 3,475
  • 21
  • 14