M
M
mrgrigo2018-08-27 01:01:54
Qt
mrgrigo, 2018-08-27 01:01:54

How to write data to application resource file?

Hello toast people.
You want to write data to a file, preferably from JavaScript or QML.
I created something similar in JavaScript:

var xhr = new XMLHttpRequest();
        xhr.open("POST", localFileUrl, false);
        writeContent = JSON.stringify(writeContent);
        xhr.setRequestHeader('Content-type', 'application/json');
        xhr.setRequestHeader('Content-Length', writeContent.length);
        xhr.send(writeContent);
        console.log(xhr.status);

No errors, status returns "0". Recording, respectively, is not performed. The data is written to a file inside the project (eg qrc:/settings/localCache.json). How can you make this miracle work?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Terekhin, 2018-08-27
@RomaZveR

Use localStorage
doc.qt.io/Qt-5/qtquick-localstorage-qmlmodule.html

J
Jacob E, 2018-08-27
@Zifix

1) Get used to reading the documentation. readonly resources.
2) It's better to work with network and files in C++.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question