Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I blame it on my tiredness but I'm struggling to find how to direct the user to a new tab via a button:

  • I've got a Login page and if the user has placed the right username and password, pressing on the Login button will direct the user to a new tab.

    TextField {
                    id: inputTo
                    placeholderText: "Username:"
    
                }
    
                TextField {
                    id: inputFrom
                    placeholderText: "password"
                    echoMode: TextInput.Password
                }
    
    
                Button {
                    objectName: "button"
                    width: parent.width
    
                    text: "Login"
    
                    onClicked: {
                        if(inputTo.text == "----" & inputFrom.text == "---" ){
                            label.text = "Succesful"
    
    
                        } else label.text = "Wrong Username or Password"
                    }
                }
    

Can anybody provide me on how to allow the button to direct the user to a new tab? thankyou :)

share|improve this question
    
its all good, managed to just create a pagestack and let the button to allow pagestack to push the new tabs ^_^. –  user140120 Mar 14 '13 at 4:06
add comment

1 Answer 1

I changed the Ubuntu-SDK tab-template to enable a password check. I am also totally new to qml but maybe this is what you want:


Project->new->ubuntu->Ubuntu-UI-Tabs as tabstest: Here is my tabstest.qml


import QtQuick 2.0
import Ubuntu.Components 0.1

/*
   example : check password before changing/showing tab
*/

MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
applicationName: "tabstest"

width: units.gu(100)
height: units.gu(75)

Tabs {
    id: tabs
    anchors.fill: parent

    // First tab begins here
    Tab {
        objectName: "Tab1"

        title: i18n.tr("Password-Entry-tab")

        // Tab content begins here
        page: Page {
            Column {
                anchors.centerIn: parent
                Label {
                    text: i18n.tr("this is the password check tab")
                }
            }
        }
        Column {
            id: pageLayout

            Label{
                id : labelX
                text : "Enter your paasword:"
            }

            TextField {
                id: inputFrom
                placeholderText: "password"
                echoMode: TextInput.Password
            }
            Button {
                objectName: "button"
                width: parent.width

                text: "Login"

                onClicked: {
                    console.debug("onclicked...");
                    if(inputFrom.text == "test" ){
                        labelX.text = "Succesful"
                        console.debug(tabs.selectedTab );
                        tabs.visible = false
                        tabs2.visible = true
                    } else {

                        labelX.text = "Wrong Username or Password"
                    }
                }
            }
        }
    }
}

Tabs {
    id: tabs2
    visible: false

    // Second tab begins here
    Tab {
        objectName: "Tab2"

        title: i18n.tr("..secured tab")
        page: Page {
            anchors.margins: units.gu(2)

            tools: ToolbarActions {
                Action {
                    objectName: "action"

                    iconSource: Qt.resolvedUrl("avatar.png")
                    text: i18n.tr("Tap me!")

                    onTriggered: {
                        label.text = i18n.tr("Toolbar tapped")
                    }
                }
            }

            Column {
                anchors.centerIn: parent
                Label {
                    id: label
                    objectName: "label"

                    text: i18n.tr("you are in secured tab.")
                }
            }
        }
    }        anchors.fill: parent
}
}

regards Sascha

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.