Results 1 to 2 of 2

Thread: Any example of StackView?

  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Any example of StackView?

    Qt5.2

    Studying StackView but have no idea how to use it.

    Qt Code:
    1. import QtQuick 2.2
    2. import QtQuick.Controls 1.1
    3.  
    4. Rectangle {
    5. id: root
    6.  
    7. width: 360
    8. height: 360
    9.  
    10. Column{
    11.  
    12. Button{
    13. width: root.width
    14. height: root.height / 10
    15.  
    16. onClicked: {
    17. stackView.push({item:Rectangle, properties: {width: root.width, height: root.height}})
    18. }
    19. }
    20.  
    21. StackView {
    22. id: stackView
    23. delegate: StackViewDelegate {
    24. function transitionFinished(properties)
    25. {
    26. properties.exitItem.opacity = 1
    27. }
    28.  
    29. property Component pushTransition: StackViewTransition {
    30. PropertyAnimation {
    31. target: enterItem
    32. property: "opacity"
    33. from: 0
    34. to: 1
    35. }
    36. PropertyAnimation {
    37. target: exitItem
    38. property: "opacity"
    39. from: 1
    40. to: 0
    41. }
    42. }
    43. }
    44. }
    45. }
    46. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Any example of StackView?

    I found an example by myself

    http://qt-project.org/doc/qt-5.1/qtq...-main-qml.html

    codes

    import QtQuick 2.1
    import QtQuick.Controls 1.0
    import "content"

    ApplicationWindow {
    width: 800
    height: 1280

    Rectangle {
    color: "#212126"
    anchors.fill: parent
    }

    // Implements back key navigation
    Keys.onReleased: {
    if (event.key === Qt.Key_Back) {
    if (stackView.depth > 1) {
    stackView.pop();
    event.accepted = true;
    } else { Qt.quit(); }
    }
    }

    toolBar: BorderImage {
    border.bottom: 8
    source: "images/toolbar.png"
    width: parent.width
    height: 100

    Rectangle {
    id: backButton
    width: opacity ? 60 : 0
    anchors.left: parent.left
    anchors.leftMargin: 20
    opacity: stackView.depth > 1 ? 1 : 0
    anchors.verticalCenter: parent.verticalCenter
    antialiasing: true
    height: 60
    radius: 4
    color: backmouse.pressed ? "#222" : "transparent"
    Behavior on opacity { NumberAnimation{} }
    Image {
    anchors.verticalCenter: parent.verticalCenter
    source: "images/navigation_previous_item.png"
    }
    MouseArea {
    id: backmouse
    anchors.fill: parent
    anchors.margins: -10
    onClicked: stackView.pop()
    }
    }

    Text {
    font.pixelSize: 42
    Behavior on x { NumberAnimation{ easing.type: Easing.OutCubic} }
    x: backButton.x + backButton.width + 20
    anchors.verticalCenter: parent.verticalCenter
    color: "white"
    text: "Widget Gallery"
    }
    }

    ListModel {
    id: pageModel
    ListElement {
    title: "Buttons"
    page: "content/ButtonPage.qml"
    }
    ListElement {
    title: "Sliders"
    page: "content/SliderPage.qml"
    }
    ListElement {
    title: "ProgressBar"
    page: "content/ProgressBarPage.qml"
    }
    ListElement {
    title: "Tabs"
    page: "content/TabBarPage.qml"
    }
    ListElement {
    title: "TextInput"
    page: "content/TextInputPage.qml"
    }
    }

    StackView {
    id: stackView
    anchors.fill: parent

    initialItem: Item {
    width: parent.width
    height: parent.height
    ListView {
    model: pageModel
    anchors.fill: parent
    delegate: AndroidDelegate {
    text: title
    onClicked: stackView.push(Qt.resolvedUrl(page))
    }
    }
    }
    }

    }

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.