How pass text form QML to Qt
-
Hi,
I test free touch keyboard in QML. It works. please tell me how pass text from keyboard to Qt. Below tested keyboard:
KeyboardInput { label: 'text to send' anchors.centerIn: parent color: "gray" width: 1000 height: 50 onAccepted: print('onAccepted', text) }
I would like to pass the
text
variable to qt. -
@jsulm said in How pass text form QML to Qt:
Do you want to pass the text to C++ part of your application?
Exactly.
To better explanation , when I write text in Textinput I getqml: onAccepted exampletext
and next I would like pass this text to my class in qt.But I don't know why is the error:
qrc:/UI/Accessories/KeyboardController.qml:35:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } qml: onAccepted exampletext
@Damian7546 said in How pass text form QML to Qt:
class in qt
Please write "class in C++". QML is also part of Qt.
Did you read https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html ?
-
Hi,
I test free touch keyboard in QML. It works. please tell me how pass text from keyboard to Qt. Below tested keyboard:
KeyboardInput { label: 'text to send' anchors.centerIn: parent color: "gray" width: 1000 height: 50 onAccepted: print('onAccepted', text) }
I would like to pass the
text
variable to qt.@Damian7546 said in How pass text form QML to Qt:
I would like to pass the text variable to qt
What do you mean?
Do you want to pass the text to C++ part of your application? -
@Damian7546 said in How pass text form QML to Qt:
I would like to pass the text variable to qt
What do you mean?
Do you want to pass the text to C++ part of your application?@jsulm said in How pass text form QML to Qt:
Do you want to pass the text to C++ part of your application?
Exactly.
To better explanation , when I write text in Textinput I getqml: onAccepted exampletext
and next I would like pass this text to my class in qt.But I don't know why is the error:
qrc:/UI/Accessories/KeyboardController.qml:35:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } qml: onAccepted exampletext
-
@jsulm said in How pass text form QML to Qt:
Do you want to pass the text to C++ part of your application?
Exactly.
To better explanation , when I write text in Textinput I getqml: onAccepted exampletext
and next I would like pass this text to my class in qt.But I don't know why is the error:
qrc:/UI/Accessories/KeyboardController.qml:35:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } qml: onAccepted exampletext
@Damian7546 said in How pass text form QML to Qt:
class in qt
Please write "class in C++". QML is also part of Qt.
Did you read https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html ?
-
Thanks for suggestion. It works!
I wrote class
SystemController
and generate code from macroQ_PROPERTY(QString text2Print READ text2Print WRITE setText2Print NOTIFY text2PrintChanged)
and registered my class in qml:
SystemController { id: systemController }
Next I change in my .qml code:
KeyboardInput { label: 'insert text' onAccepted: print('onAccepted', systemController.text2Print = text) }
Can you help me with below error, How can I remove this?
qrc:/UI/Accessories/KeyboardController.qml:35:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }
Here is a line with a problem:
Connections { target: keyboard onAccepted: { root.accepted(text) // emit keyboard.destroy() // hide } onRejected: keyboard.destroy() // hide }
-
Thanks for suggestion. It works!
I wrote class
SystemController
and generate code from macroQ_PROPERTY(QString text2Print READ text2Print WRITE setText2Print NOTIFY text2PrintChanged)
and registered my class in qml:
SystemController { id: systemController }
Next I change in my .qml code:
KeyboardInput { label: 'insert text' onAccepted: print('onAccepted', systemController.text2Print = text) }
Can you help me with below error, How can I remove this?
qrc:/UI/Accessories/KeyboardController.qml:35:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }
Here is a line with a problem:
Connections { target: keyboard onAccepted: { root.accepted(text) // emit keyboard.destroy() // hide } onRejected: keyboard.destroy() // hide }
@Damian7546 said in How pass text form QML to Qt:
QML Connections: Implicitly defined onFoo properties in Connections are deprecated
It is warning, But can you try? Text is not passed to the func explicitly
onAccepted(text): { root.accepted(text) // emit keyboard.destroy() // hide }
-
@Damian7546 said in How pass text form QML to Qt:
Can you help me with below error, How can I remove this?
Instead of
Connections { onAccepted: ...
you need to write
Connections { function onAccepted(..) { }