View Single Post
Posts: 241 | Thanked: 324 times | Joined on Dec 2010
#9
I tried to get a search box that occupies almost the length of the header, but I think it is a bit messy, also the height is an arbitrary height I put. Is there a cleaner way to achieve this? It's quite hardcoded ratch right now. The default textfield element that the SDK provides is probably like half the width of the screen....here's the code
Code:
Page {
    tools: commonTools

    Label {
        id: label
        anchors.centerIn: parent
        text: qsTr("Hello world!")
        visible: false
    }

    Rectangle {
        id: header
        height: 72
        width: parent.width
        color: "light blue"

        Rectangle {
        id: boundbox
        height: 50
        anchors.centerIn: parent
        width: 448
        color: "transparent"

            TextField {
                id: searchBox
                placeholderText: "Search"
                maximumLength: 80
                anchors.fill: boundbox
               }
           }
    }
}