App stays on white screen after being reopened
Unsolved
QML and Qt Quick
-
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?
-
@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() } } } }