populate global variable

226
1
Jump to solution
12-23-2019 07:26 AM
jaykapalczynski
Frequent Contributor

Working in the Quick report Template I can see how they are creating variables in the QuickReportApp.qml

These variables are set and reference through the application with app.somevariablename

App {
    id: app

What I am trying to do is sort of the opposite.  

I am trying to set a variable inside UserCredentialsView.qml file and update the value back in the QuickReportApp.qml 

Thus creating a GLOBAL variable that I can reference from Anywhere in my app.

My confusion is that all the Authentication qml files have the same ID so I can figure out how to call them individually

So this is why I am thinking of pushing the value back to the QuickReportApp.qml somehow...

I might be going about this wrong.  Anyone have better idea on how to create a global id that can be referenced by ANY qml file and that gets populated withing the UsercredentialsView.qml?????

0 Kudos
1 Solution

Accepted Solutions
jaykapalczynski
Frequent Contributor

 got it....

QuickReportApp.qml

    property string userCredentialsName: ""

On click of the Continue button I set this Public Variable in the UserCredentialsView.qml

            Button {
                id: continueButton
                width: ((parent.width / 2) - 2 * displayScaleFactor)
                text: qsTr("Continue")

                onClicked: {

                    // continue with the username and password
                    if (challenge)
                        challenge.continueWithUsernamePassword(usernameTextField.text, passwordTextField.text);
                    rootUser.visible = false;

                    app.userCredentialsName = usernameTextField.text;

                }
            }

View solution in original post

0 Kudos
1 Reply
jaykapalczynski
Frequent Contributor

 got it....

QuickReportApp.qml

    property string userCredentialsName: ""

On click of the Continue button I set this Public Variable in the UserCredentialsView.qml

            Button {
                id: continueButton
                width: ((parent.width / 2) - 2 * displayScaleFactor)
                text: qsTr("Continue")

                onClicked: {

                    // continue with the username and password
                    if (challenge)
                        challenge.continueWithUsernamePassword(usernameTextField.text, passwordTextField.text);
                    rootUser.visible = false;

                    app.userCredentialsName = usernameTextField.text;

                }
            }
0 Kudos