View Full Version : Implementing Save Feature in Javascript app using Qt

11th August 2010, 14:01

I have an application written in JavaScript. I am trying to port it on on Maemo Platform using Qt.

I am facing problems in implementing "Save feature" to it. Whatever data I write on my application is saved in a "string" in a dosave() function of my JavaScript file.

I am using this code to interact with JavaScript function:

void Test::on_pushButton2_clicked()

QVariant name;

QString fileName = QFileDialog::getSaveFileName(this,
tr("Save file"), "",
tr("Myapp (*.app);;All Files (*)"));

if (fileName.isEmpty())
else {
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("Unable to open file"),

name = webView->page()->mainFrame()->evaluateJavaScript("dosave()");

I am able to save my file but when I open it , I get blank file again with no data in it.
I am not able retrieve data.

Kindly suggest some solution to my problem.
What are the ways I can save the data returned by the JavaScript function and can get back same thing on my file when I open it.
How can I implement data structures or Hash table in Qt programming, where I can save the strings returned and then use them in function created in Javascript used to open my saved files ?
Kindly suggest some solutions.

16th August 2010, 07:27
In which line of code of your example do you think does the actual write to the file happen?