Set QML_XHR_ALLOW_FILE_READ in python
-
I want to read a local file directly using QML. But I'm getting this warning/error:
XMLHttpRequest: Using GET on a local file is dangerous and will be disabled by default in a future Qt version.Set QML_XHR_ALLOW_FILE_READ to 1 if you wish to continue using this feature.
Here is says I should use the
qputenv()
to set the environment variable.https://www.reddit.com/r/QtFramework/comments/mh9oqi/local_files_with_qml/
However this is for C++, how would that be done in python (PySide2)? I couldn't fine an equivalent function from PySide2
-
os.environ["QML_XHR_ALLOW_FILE_READ"] = "1"
should work I guess : https://docs.python.org/3/library/os.html#os.environ