Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. App stays on white screen after being reopened

App stays on white screen after being reopened

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 646 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ivelin
    wrote on last edited by Ivelin
    #1

    Hello,

    I have 2 qml files.

    The first one sends a request to see if the user is authorized and if he is it redirects him to the main qml file and if he is not he goes to an authetnication qml file, but I do not think the auth qml file is the problem here.

    Here is my main.qml file

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.5
    import QtQuick.Layouts 1.3
    import QtQuick.Controls.Fusion 2.3
    import QtQuick.Controls.Material 2.5
    
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        font.family: "Montserrat"
    
        Material.theme: Material.Light
        Material.accent: "#001b2a"
    
        Loader {
           id: componentLoader
           anchors.centerIn: parent
    
        }
    
        Component.onCompleted: {
             networkManager.authenticated_get("http://192.168.1.10:5000/api/authenticate");
        }
    
        Connections {
            target: networkManager
            ignoreUnknownSignals: true
    
    
            function onOperationFinished(responseData, isError) {
            console.log(responseData);
                var json = JSON.parse(networkManager.convertToJsonString(responseData));
    
                if(isError) {
                   componentLoader.source = "Auth.qml"
                   return;
                }
                console.log(json.auth_token);
                storageManager.attachAuthToken(json.auth_token);
                console.log(storageManager.getAuthToken());
                componentLoader.source = "home.qml"
                
            }
        }
    }
    

    after the request onOperationFinished is called and I get redirect to the main.qml file which is this one:

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Controls.Material
    import QtQuick.Window
    import Qt.labs.settings
    
    ApplicationWindow {
        id: appWindow
        minimumWidth: 480
        minimumHeight: 960
    
        flags: Qt.Window
        color: "white"
        visible: true
    
        property string cameraOption: "camera"
        property string locationOption: "camera"
        property string bootOption: "camera"
    
        Loader {
           id: componentLoader
           anchors.centerIn: parent
    
        }
    
        Rectangle {
            id: topRect
            anchors.top: parent.top
            anchors.left: parent.left
            anchors.right: parent.right
            height: 52
            color: "#f1f3f5"
    
            Text {
                anchors.left: parent.left
                anchors.leftMargin: 16
                anchors.verticalCenter: parent.verticalCenter
                text: "SecureMe"
                font.pixelSize: 20
            }
            Text {
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                anchors.rightMargin: 16
                text: "Logout"
                font.family: "Helvetica"
                font.pointSize: 24
                color: "#00c1c9"
    
                MouseArea {
                anchors.fill: parent
                    onClicked: {
                        storageManager.attachAuthToken("");
                        console.log(storageManager.getAuthToken());
                        componentLoader.source = "main.qml"
                    }
                }
            }
        }
    
        Column {
            spacing: 20
            anchors.top: topRect.bottom
            anchors.topMargin: 20
            id: here
    
            Row {
                spacing: 10
    
                CheckBox {
                    id: locationBox
                    anchors.verticalCenter: parent.verticalCenter
                    checked: true
                    onClicked: storageManager.switchSetting(locationOption)
    
                }
    
                Column {
                    spacing: 2
    
                    Text {
                        text: "Следене на устройството"
                        font.bold: true
                    }
    
                    Text {
                        text: "При влизане в админ панела за октриване на съотвентото устройство ще се включи локацията на телефона, за да се проследи."
                        wrapMode: Text.WordWrap
                    }
                }
            }
    
            Row {
                spacing: 10
    
                CheckBox {
                    id: bootBox
                    anchors.verticalCenter: parent.verticalCenter
                    checked: storageManager.getSettingSwitch(bootOption)
                    onClicked: storageManager.switchSetting(bootOption)
                }
    
                Column {
                    spacing: 2
    
                    Text {
                        text: "Известяване при стартиране"
                        font.bold: true
                    }
    
                    Text {
                        text: "При включване на текущото устройство всички навързани устройства ще бъдат известявани."
                        wrapMode: Text.WordWrap
                    }
                }
            }
    
            Row {
                spacing: 10
    
                CheckBox {
                    id: incorrectPasswordBox
                    anchors.verticalCenter: parent.verticalCenter
                    checked: storageManager.getSettingSwitch(cameraOption)
                    onClicked: storageManager.switchSetting(cameraOption)
                }
    
                Column {
                    spacing: 2
    
                    Text {
                        text: "Известяване при сгрешена парола"
                        font.bold: true
                    }
    
                    Text {
                        text: "При грешене на паролата на текущото устройство всички навързани устройства ще бъдат."
                        wrapMode: Text.WordWrap
                    }
                }
            }
        }
    }
    

    It is a simple file with lots of information. However, when I reopen the app, without closing it. I get a white forever screen.

    Why is that? Could someone help me out here?

    GrecKoG JoeCFDJ 2 Replies Last reply
    0
    • I Ivelin

      Hello,

      I have 2 qml files.

      The first one sends a request to see if the user is authorized and if he is it redirects him to the main qml file and if he is not he goes to an authetnication qml file, but I do not think the auth qml file is the problem here.

      Here is my main.qml file

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.5
      import QtQuick.Layouts 1.3
      import QtQuick.Controls.Fusion 2.3
      import QtQuick.Controls.Material 2.5
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
          font.family: "Montserrat"
      
          Material.theme: Material.Light
          Material.accent: "#001b2a"
      
          Loader {
             id: componentLoader
             anchors.centerIn: parent
      
          }
      
          Component.onCompleted: {
               networkManager.authenticated_get("http://192.168.1.10:5000/api/authenticate");
          }
      
          Connections {
              target: networkManager
              ignoreUnknownSignals: true
      
      
              function onOperationFinished(responseData, isError) {
              console.log(responseData);
                  var json = JSON.parse(networkManager.convertToJsonString(responseData));
      
                  if(isError) {
                     componentLoader.source = "Auth.qml"
                     return;
                  }
                  console.log(json.auth_token);
                  storageManager.attachAuthToken(json.auth_token);
                  console.log(storageManager.getAuthToken());
                  componentLoader.source = "home.qml"
                  
              }
          }
      }
      

      after the request onOperationFinished is called and I get redirect to the main.qml file which is this one:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Controls.Material
      import QtQuick.Window
      import Qt.labs.settings
      
      ApplicationWindow {
          id: appWindow
          minimumWidth: 480
          minimumHeight: 960
      
          flags: Qt.Window
          color: "white"
          visible: true
      
          property string cameraOption: "camera"
          property string locationOption: "camera"
          property string bootOption: "camera"
      
          Loader {
             id: componentLoader
             anchors.centerIn: parent
      
          }
      
          Rectangle {
              id: topRect
              anchors.top: parent.top
              anchors.left: parent.left
              anchors.right: parent.right
              height: 52
              color: "#f1f3f5"
      
              Text {
                  anchors.left: parent.left
                  anchors.leftMargin: 16
                  anchors.verticalCenter: parent.verticalCenter
                  text: "SecureMe"
                  font.pixelSize: 20
              }
              Text {
                  anchors.right: parent.right
                  anchors.verticalCenter: parent.verticalCenter
                  anchors.rightMargin: 16
                  text: "Logout"
                  font.family: "Helvetica"
                  font.pointSize: 24
                  color: "#00c1c9"
      
                  MouseArea {
                  anchors.fill: parent
                      onClicked: {
                          storageManager.attachAuthToken("");
                          console.log(storageManager.getAuthToken());
                          componentLoader.source = "main.qml"
                      }
                  }
              }
          }
      
          Column {
              spacing: 20
              anchors.top: topRect.bottom
              anchors.topMargin: 20
              id: here
      
              Row {
                  spacing: 10
      
                  CheckBox {
                      id: locationBox
                      anchors.verticalCenter: parent.verticalCenter
                      checked: true
                      onClicked: storageManager.switchSetting(locationOption)
      
                  }
      
                  Column {
                      spacing: 2
      
                      Text {
                          text: "Следене на устройството"
                          font.bold: true
                      }
      
                      Text {
                          text: "При влизане в админ панела за октриване на съотвентото устройство ще се включи локацията на телефона, за да се проследи."
                          wrapMode: Text.WordWrap
                      }
                  }
              }
      
              Row {
                  spacing: 10
      
                  CheckBox {
                      id: bootBox
                      anchors.verticalCenter: parent.verticalCenter
                      checked: storageManager.getSettingSwitch(bootOption)
                      onClicked: storageManager.switchSetting(bootOption)
                  }
      
                  Column {
                      spacing: 2
      
                      Text {
                          text: "Известяване при стартиране"
                          font.bold: true
                      }
      
                      Text {
                          text: "При включване на текущото устройство всички навързани устройства ще бъдат известявани."
                          wrapMode: Text.WordWrap
                      }
                  }
              }
      
              Row {
                  spacing: 10
      
                  CheckBox {
                      id: incorrectPasswordBox
                      anchors.verticalCenter: parent.verticalCenter
                      checked: storageManager.getSettingSwitch(cameraOption)
                      onClicked: storageManager.switchSetting(cameraOption)
                  }
      
                  Column {
                      spacing: 2
      
                      Text {
                          text: "Известяване при сгрешена парола"
                          font.bold: true
                      }
      
                      Text {
                          text: "При грешене на паролата на текущото устройство всички навързани устройства ще бъдат."
                          wrapMode: Text.WordWrap
                      }
                  }
              }
          }
      }
      

      It is a simple file with lots of information. However, when I reopen the app, without closing it. I get a white forever screen.

      Why is that? Could someone help me out here?

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      is onOperationFinished called the second time?

      I 1 Reply Last reply
      0
      • I Ivelin

        Hello,

        I have 2 qml files.

        The first one sends a request to see if the user is authorized and if he is it redirects him to the main qml file and if he is not he goes to an authetnication qml file, but I do not think the auth qml file is the problem here.

        Here is my main.qml file

        import QtQuick 2.15
        import QtQuick.Window 2.15
        import QtQuick.Controls 2.5
        import QtQuick.Layouts 1.3
        import QtQuick.Controls.Fusion 2.3
        import QtQuick.Controls.Material 2.5
        
        ApplicationWindow {
            width: 640
            height: 480
            visible: true
            font.family: "Montserrat"
        
            Material.theme: Material.Light
            Material.accent: "#001b2a"
        
            Loader {
               id: componentLoader
               anchors.centerIn: parent
        
            }
        
            Component.onCompleted: {
                 networkManager.authenticated_get("http://192.168.1.10:5000/api/authenticate");
            }
        
            Connections {
                target: networkManager
                ignoreUnknownSignals: true
        
        
                function onOperationFinished(responseData, isError) {
                console.log(responseData);
                    var json = JSON.parse(networkManager.convertToJsonString(responseData));
        
                    if(isError) {
                       componentLoader.source = "Auth.qml"
                       return;
                    }
                    console.log(json.auth_token);
                    storageManager.attachAuthToken(json.auth_token);
                    console.log(storageManager.getAuthToken());
                    componentLoader.source = "home.qml"
                    
                }
            }
        }
        

        after the request onOperationFinished is called and I get redirect to the main.qml file which is this one:

        import QtQuick
        import QtQuick.Controls
        import QtQuick.Controls.Material
        import QtQuick.Window
        import Qt.labs.settings
        
        ApplicationWindow {
            id: appWindow
            minimumWidth: 480
            minimumHeight: 960
        
            flags: Qt.Window
            color: "white"
            visible: true
        
            property string cameraOption: "camera"
            property string locationOption: "camera"
            property string bootOption: "camera"
        
            Loader {
               id: componentLoader
               anchors.centerIn: parent
        
            }
        
            Rectangle {
                id: topRect
                anchors.top: parent.top
                anchors.left: parent.left
                anchors.right: parent.right
                height: 52
                color: "#f1f3f5"
        
                Text {
                    anchors.left: parent.left
                    anchors.leftMargin: 16
                    anchors.verticalCenter: parent.verticalCenter
                    text: "SecureMe"
                    font.pixelSize: 20
                }
                Text {
                    anchors.right: parent.right
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.rightMargin: 16
                    text: "Logout"
                    font.family: "Helvetica"
                    font.pointSize: 24
                    color: "#00c1c9"
        
                    MouseArea {
                    anchors.fill: parent
                        onClicked: {
                            storageManager.attachAuthToken("");
                            console.log(storageManager.getAuthToken());
                            componentLoader.source = "main.qml"
                        }
                    }
                }
            }
        
            Column {
                spacing: 20
                anchors.top: topRect.bottom
                anchors.topMargin: 20
                id: here
        
                Row {
                    spacing: 10
        
                    CheckBox {
                        id: locationBox
                        anchors.verticalCenter: parent.verticalCenter
                        checked: true
                        onClicked: storageManager.switchSetting(locationOption)
        
                    }
        
                    Column {
                        spacing: 2
        
                        Text {
                            text: "Следене на устройството"
                            font.bold: true
                        }
        
                        Text {
                            text: "При влизане в админ панела за октриване на съотвентото устройство ще се включи локацията на телефона, за да се проследи."
                            wrapMode: Text.WordWrap
                        }
                    }
                }
        
                Row {
                    spacing: 10
        
                    CheckBox {
                        id: bootBox
                        anchors.verticalCenter: parent.verticalCenter
                        checked: storageManager.getSettingSwitch(bootOption)
                        onClicked: storageManager.switchSetting(bootOption)
                    }
        
                    Column {
                        spacing: 2
        
                        Text {
                            text: "Известяване при стартиране"
                            font.bold: true
                        }
        
                        Text {
                            text: "При включване на текущото устройство всички навързани устройства ще бъдат известявани."
                            wrapMode: Text.WordWrap
                        }
                    }
                }
        
                Row {
                    spacing: 10
        
                    CheckBox {
                        id: incorrectPasswordBox
                        anchors.verticalCenter: parent.verticalCenter
                        checked: storageManager.getSettingSwitch(cameraOption)
                        onClicked: storageManager.switchSetting(cameraOption)
                    }
        
                    Column {
                        spacing: 2
        
                        Text {
                            text: "Известяване при сгрешена парола"
                            font.bold: true
                        }
        
                        Text {
                            text: "При грешене на паролата на текущото устройство всички навързани устройства ще бъдат."
                            wrapMode: Text.WordWrap
                        }
                    }
                }
            }
        }
        

        It is a simple file with lots of information. However, when I reopen the app, without closing it. I get a white forever screen.

        Why is that? Could someone help me out here?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @Ivelin Is the second file home.qml?
        from here in your first qml

        componentLoader.source = "home.qml"
        

        if true, you have two ApplicationWindow

        I 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          @Ivelin Is the second file home.qml?
          from here in your first qml

          componentLoader.source = "home.qml"
          

          if true, you have two ApplicationWindow

          I Offline
          I Offline
          Ivelin
          wrote on last edited by
          #4

          @JoeCF, I am terribly sorry that I answer with such delay, but I didnt' get any notificaitons!

          Yes, the second file is home.qml so what? It doesn't get to there?

          1 Reply Last reply
          0
          • GrecKoG GrecKo

            is onOperationFinished called the second time?

            I Offline
            I Offline
            Ivelin
            wrote on last edited by Ivelin
            #5

            @GrecKo, I am terribly sorry for the delay. I didn't get any notifications! It seems it isn't being called second time. No request is being sent the second time to my server.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Ivelin
              wrote on last edited by
              #6

              I still have the same issue..

              T 1 Reply Last reply
              0
              • I Ivelin

                I still have the same issue..

                T Offline
                T Offline
                trin94
                wrote on last edited by
                #7

                @Ivelin It is really difficult to understand what you are trying to achieve.

                Are you trying to trigger the re-authentication like this? If so, what about this approach?

                Foo.qml

                import QtQuick
                import QtQuick.Controls.Material
                
                ApplicationWindow {
                    id: root
                
                    width: 640
                    height: 640
                    visible: true
                
                    Material.theme: Material.Dark
                
                    Loader {
                        id: loader
                    }
                
                    function authenticate() {
                        loader.sourceComponent = null
                        loader.sourceComponent = barComponent
                    }
                
                    Component.onCompleted: root.authenticate()
                
                    Item {
                        anchors.centerIn: parent
                
                        Label {
                            id: label
                
                            text: "Let's try this"
                            anchors.centerIn: parent
                        }
                    }
                
                    Component {
                        id: barComponent
                
                        Bar {
                            onSucceeded: message => {
                                label.text = "Succeeded " + message
                            }
                
                            onFailed: message => {
                                label.text = "I'll try again because " + message
                                root.authenticate()
                            }
                        }
                    }
                }
                

                Bar.qml

                import QtQuick.Controls.Material
                import QtQuick.Layouts
                
                ApplicationWindow {
                    id: root
                
                    width: 320
                    height: 320
                    visible: true
                
                    Material.theme: Material.Light
                
                    signal succeeded(message: string)
                    signal failed(message: string)
                
                    RowLayout {
                        Button {
                            text: 'success'
                
                            onClicked: {
                                root.succeeded('yay!!')
                                root.close()
                            }
                        }
                
                        Button {
                            text: 'failure'
                
                            onClicked: {
                                root.failed('I failed')
                                root.close()
                            }
                        }
                    }
                
                }
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved