Important: Please read the Qt Code of Conduct -

Make an XMLHttpRequest on Android

  • Hi all,
    I'm trying to perform an XMLHttpRequest in QML over plain HTTP inside my LAN. It works well on my computer, but it fails once deployed on an Android device with status 0.
    My goal was to build my app using CMake but I couldn't make the AndroidManifest.xml working so I'm trying this from a QMake-built app (where the android manifest is working). So I added android.permission.INTERNET but the request still ends up with status 0.

    My test qmake app is very simple, I created it as an empty QtQuick template from QtCreator and this is my main.qml.

    import QtQuick 2.12
    import QtQuick.Window 2.12
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
        Component.onCompleted: updateModel()
        function updateModel() {
            var doc = new XMLHttpRequest();
            doc.onreadystatechange = function() {
                if (doc.readyState === XMLHttpRequest.DONE) {
                    console.log("status req: "+doc.status)
                    if (doc.status === 200) {
  "GET", "");

    I am using Qt5.12.10.
    What am I doing wrong in this http call? Why it does return with status 0?
    If I need to give you some other details, please tell me.
    Thank you!

Log in to reply