How to save the Text in QML?
-
Dear Friends,
I need to get input(like user details) from the user and save it in a local file.txt. I'm using QML for designing and c++ backend. Or is there any way to save the file directly from QML?. can any one please help... -
I would do the "business logic" in the c++ backend and provide a nice interface to Qml.
-
[quote author="5mahesh" date="1323343775"]Or is there any way to save the file directly from QML?.[/quote]
No, there's just the "Offline Storage API.":http://doc.qt.nokia.com/latest/qdeclarativeglobalobject.html#offline-storage-api
-
I'm using QSettings for this. Check out my thread:
http://developer.qt.nokia.com/forums/viewthread/11696/ -
QtQuick - How can I save user input if I have this code?
@import QtQuick 2.0
import QtQuick.Controls 1.1
//import "../qtquickapp1/ButtonItem.qml"
Rectangle {
id:parent
objectName: "Agenda Personala"
color:"lightyellow"
width: 360
height: 360
Row{
id:meniu
anchors.top: parent.top
ColorAnimation { from: "white"; to: "black"; duration: 200 }
Button{
text:qsTr("Inchide")
onClicked: Qt.quit()
}
Button{
id:salveaza
text: qsTr("Salveaza")
signal trigger
MouseArea{
anchors.fill: salveaza
onPressed: parent.color="lightgreen"
onReleased: parent.color="white"
}
}
//onTrigger: console.log("Semnal emis!")
Button{
text: qsTr("Deschide", "Open")
tooltip: "Deschide"
}
}
Row{
id: intdate
anchors.top: meniu.bottom
anchors.verticalCenter: parent.verticalCenter
//anchors.verticalCenter: parent
//color:"lightblue"
Label{
text: qsTr("Nume/Prenume: ")
}
TextInput{
id:numeTi
text:qsTr(" Nume ")
color: focus?"red":"green"
maximumLength: 15
focus: true
KeyNavigation.tab: telefonTi
}
Label{
text:qsTr(" Nr. Telefon: ")
}
TextInput{
id:telefonTi
text: qsTr("Telefon")
color: focus ? "red" : "green"
maximumLength: 20
KeyNavigation.backtab: numeTi} } Row{ anchors.top: intdate.bottom anchors.verticalCenter: parent.verticalCenter Label{ text:numeTi.text+" "+telefonTi.text } }
}
@