Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Place Button in Bottom of page

Place Button in Bottom of page

Scheduled Pinned Locked Moved QML and Qt Quick
qt quickbutton
8 Posts 3 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • QjayQ Offline
    QjayQ Offline
    Qjay
    wrote on last edited by
    #1

    I have this layout of a page .

    https://s32.postimg.org/ljq549cat/image.png

    I want to place those buttons in bottom center with small gap

    code :

    import QtQuick 2.6
    import QtQuick.Layouts 1.1
    import QtQuick.Controls 2.0
    
    Pane {
        padding: 0
    
        property var delegateComponentMap: {
            "page": itemDelegateComponent
    
        }
    
        Component {
            id: itemDelegateComponent
    
            ItemDelegate {
                text: labelText
                width: parent.width
            }
        }
    
    
    
    
    
    
        ColumnLayout {
            id: column
            spacing: 40
            anchors.fill: parent
            anchors.topMargin: 20
    
            Label {
                Layout.fillWidth: true
                wrapMode: Label.Wrap
                horizontalAlignment: Qt.AlignHCenter
                text: "Offline Pages "
            }
    
            ListView {
                id: listView
                Layout.fillWidth: true
                Layout.fillHeight: true
                clip: true
                model: ListModel {
                    ListElement { type: "ItemDelegate"; text: "page" }
                    ListElement { type: "ItemDelegate"; text: "page" }
                    ListElement { type: "ItemDelegate"; text: "page" }
    
                }
    
                section.property: "type"
                section.delegate: Pane {
                    width: listView.width
                    height: sectionLabel.implicitHeight + 20
    
                    Label {
                        id: sectionLabel
                        text: ""
                        anchors.centerIn: parent
                    }
                }
    
                delegate: Loader {
                    id: delegateLoader
                    width: listView.width
                    sourceComponent: delegateComponentMap[text]
    
                    property string labelText: text
                    property ListView view: listView
                    property int ourIndex: index
    
    
                    ListView.onRemove: SequentialAnimation {
                        PropertyAction {
                            target: delegateLoader
                            property: "ListView.delayRemove"
                            value: true
                        }
                        NumberAnimation {
                            target: item
                            property: "height"
                            to: 0
                            easing.type: Easing.InOutQuad
                        }
                        PropertyAction {
                            target: delegateLoader
                            property: "ListView.delayRemove"
                            value: false
                        }
                    }
                }
            }
        }
    
    
       RowLayout{
            anchors.verticalCenter: parent.verticalCenter
            Button{
                text:"Update"
    
    
            }
            Button{
                text:"Delete"
            }
        }
    }
    
    M 1 Reply Last reply
    0
    • QjayQ Qjay

      I have this layout of a page .

      https://s32.postimg.org/ljq549cat/image.png

      I want to place those buttons in bottom center with small gap

      code :

      import QtQuick 2.6
      import QtQuick.Layouts 1.1
      import QtQuick.Controls 2.0
      
      Pane {
          padding: 0
      
          property var delegateComponentMap: {
              "page": itemDelegateComponent
      
          }
      
          Component {
              id: itemDelegateComponent
      
              ItemDelegate {
                  text: labelText
                  width: parent.width
              }
          }
      
      
      
      
      
      
          ColumnLayout {
              id: column
              spacing: 40
              anchors.fill: parent
              anchors.topMargin: 20
      
              Label {
                  Layout.fillWidth: true
                  wrapMode: Label.Wrap
                  horizontalAlignment: Qt.AlignHCenter
                  text: "Offline Pages "
              }
      
              ListView {
                  id: listView
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  clip: true
                  model: ListModel {
                      ListElement { type: "ItemDelegate"; text: "page" }
                      ListElement { type: "ItemDelegate"; text: "page" }
                      ListElement { type: "ItemDelegate"; text: "page" }
      
                  }
      
                  section.property: "type"
                  section.delegate: Pane {
                      width: listView.width
                      height: sectionLabel.implicitHeight + 20
      
                      Label {
                          id: sectionLabel
                          text: ""
                          anchors.centerIn: parent
                      }
                  }
      
                  delegate: Loader {
                      id: delegateLoader
                      width: listView.width
                      sourceComponent: delegateComponentMap[text]
      
                      property string labelText: text
                      property ListView view: listView
                      property int ourIndex: index
      
      
                      ListView.onRemove: SequentialAnimation {
                          PropertyAction {
                              target: delegateLoader
                              property: "ListView.delayRemove"
                              value: true
                          }
                          NumberAnimation {
                              target: item
                              property: "height"
                              to: 0
                              easing.type: Easing.InOutQuad
                          }
                          PropertyAction {
                              target: delegateLoader
                              property: "ListView.delayRemove"
                              value: false
                          }
                      }
                  }
              }
          }
      
      
         RowLayout{
              anchors.verticalCenter: parent.verticalCenter
              Button{
                  text:"Update"
      
      
              }
              Button{
                  text:"Delete"
              }
          }
      }
      
      M Offline
      M Offline
      medyakovvit
      wrote on last edited by
      #2

      @Qjay
      Try to to move RowLayout with buttons in ColumnLayout:

      ColumnLayout{
          // ...
          Label{
            //...
          }
          ListView{
            //...
          }
      
          RowLayout{
              Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
      
              Button{}
              Button{}
          }
      }
      
      1 Reply Last reply
      1
      • QjayQ Offline
        QjayQ Offline
        Qjay
        wrote on last edited by Qjay
        #3

        hey @medyakovvit . It worked Thanks !!

        I have 1 more request . We need a small change .

        Currently the UI looks like this ( which i initially wanted )

        https://s31.postimg.org/5tto84qsr/manage.png

        now i want 2 buttons on each page(delegates) .

        what i want to achieve is this

        page button(delete) button(update)
        page button(delete) button(update)
        page button(delete) button(update)

             Update all      Delete all 
        

        Code :

        import QtQuick 2.6
        import QtQuick.Layouts 1.1
        import QtQuick.Controls 2.0
        
        Pane {
            padding: 0
        
            property var delegateComponentMap: {
                "page": itemDelegateComponent
        
            }
        
            Component {
                id: itemDelegateComponent
        
                ItemDelegate {
                    text: labelText
                    width: parent.width
                }
            }
        
        
        
        
        
        
            ColumnLayout {
                id: column
                spacing: 40
                anchors.fill: parent
                anchors.topMargin: 20
        
                Label {
                    Layout.fillWidth: true
                    wrapMode: Label.Wrap
                    horizontalAlignment: Qt.AlignHCenter
                    text: "Offline Pages "
                }
        
                ListView {
                    id: listView
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    clip: true
                    model: ListModel {
                        ListElement { type: "ItemDelegate"; text: "page1" }
                        ListElement { type: "ItemDelegate"; text: "page2" }
                        ListElement { type: "ItemDelegate"; text: "page3" }
        
                    }
        
                    section.property: "type"
                    section.delegate: Pane {
                        width: listView.width
                        height: sectionLabel.implicitHeight + 20
        
                        Label {
                            id: sectionLabel
        
                            anchors.centerIn: parent
                        }
                    }
        
                    delegate: Loader {
                        id: delegateLoader
                        width: listView.width
                        sourceComponent: delegateComponentMap[text]
        
                        property string labelText: text
                        property ListView view: listView
                        property int ourIndex: index
        
        
                        ListView.onRemove: SequentialAnimation {
                            PropertyAction {
                                target: delegateLoader
                                property: "ListView.delayRemove"
                                value: true
                            }
                            NumberAnimation {
                                target: item
                                property: "height"
                                to: 0
                                easing.type: Easing.InOutQuad
                            }
                            PropertyAction {
                                target: delegateLoader
                                property: "ListView.delayRemove"
                                value: false
                            }
                        }
                    }
                }
        
        
        
           RowLayout{
                Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
        
                Button{
                    text:"Update"
        
        
                }
                Button{
                    text:"Delete"
                }
              }
           }
        }
        
        M 1 Reply Last reply
        0
        • QjayQ Qjay

          hey @medyakovvit . It worked Thanks !!

          I have 1 more request . We need a small change .

          Currently the UI looks like this ( which i initially wanted )

          https://s31.postimg.org/5tto84qsr/manage.png

          now i want 2 buttons on each page(delegates) .

          what i want to achieve is this

          page button(delete) button(update)
          page button(delete) button(update)
          page button(delete) button(update)

               Update all      Delete all 
          

          Code :

          import QtQuick 2.6
          import QtQuick.Layouts 1.1
          import QtQuick.Controls 2.0
          
          Pane {
              padding: 0
          
              property var delegateComponentMap: {
                  "page": itemDelegateComponent
          
              }
          
              Component {
                  id: itemDelegateComponent
          
                  ItemDelegate {
                      text: labelText
                      width: parent.width
                  }
              }
          
          
          
          
          
          
              ColumnLayout {
                  id: column
                  spacing: 40
                  anchors.fill: parent
                  anchors.topMargin: 20
          
                  Label {
                      Layout.fillWidth: true
                      wrapMode: Label.Wrap
                      horizontalAlignment: Qt.AlignHCenter
                      text: "Offline Pages "
                  }
          
                  ListView {
                      id: listView
                      Layout.fillWidth: true
                      Layout.fillHeight: true
                      clip: true
                      model: ListModel {
                          ListElement { type: "ItemDelegate"; text: "page1" }
                          ListElement { type: "ItemDelegate"; text: "page2" }
                          ListElement { type: "ItemDelegate"; text: "page3" }
          
                      }
          
                      section.property: "type"
                      section.delegate: Pane {
                          width: listView.width
                          height: sectionLabel.implicitHeight + 20
          
                          Label {
                              id: sectionLabel
          
                              anchors.centerIn: parent
                          }
                      }
          
                      delegate: Loader {
                          id: delegateLoader
                          width: listView.width
                          sourceComponent: delegateComponentMap[text]
          
                          property string labelText: text
                          property ListView view: listView
                          property int ourIndex: index
          
          
                          ListView.onRemove: SequentialAnimation {
                              PropertyAction {
                                  target: delegateLoader
                                  property: "ListView.delayRemove"
                                  value: true
                              }
                              NumberAnimation {
                                  target: item
                                  property: "height"
                                  to: 0
                                  easing.type: Easing.InOutQuad
                              }
                              PropertyAction {
                                  target: delegateLoader
                                  property: "ListView.delayRemove"
                                  value: false
                              }
                          }
                      }
                  }
          
          
          
             RowLayout{
                  Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
          
                  Button{
                      text:"Update"
          
          
                  }
                  Button{
                      text:"Delete"
                  }
                }
             }
          }
          
          M Offline
          M Offline
          medyakovvit
          wrote on last edited by
          #4

          @Qjay said:
          And what it's ItemDelegate?

          1 Reply Last reply
          0
          • QjayQ Offline
            QjayQ Offline
            Qjay
            wrote on last edited by
            #5

            @medyakovvit i posted the wrong code before ( had 2 files with almost same name )

            Please see it now

            M 1 Reply Last reply
            0
            • QjayQ Qjay

              @medyakovvit i posted the wrong code before ( had 2 files with almost same name )

              Please see it now

              M Offline
              M Offline
              medyakovvit
              wrote on last edited by
              #6

              @Qjay

              it's just listview without using ItemDelegate:

              ListView {
                          id: listView
                          Layout.fillWidth: true
                          Layout.fillHeight: true
                          clip: true
                          model: ListModel {
                              ListElement { type: "ItemDelegate"; labelText: "page1" }
                              ListElement { type: "ItemDelegate"; labelText: "page2" }
                              ListElement { type: "ItemDelegate"; labelText: "page3" }
              
                          }
                          spacing: 5
              
                          section.property: "type"
              
                          delegate: Component{
              
                              Item{
                                  id: aItem
                                  width: rowLayout.width
                                  height: 30
              
                                  RowLayout{
                                      id: rowLayout
                                      anchors.fill: parent
                                      spacing: 5
              
                                      Label{
                                          text: labelText
                                      }
              
                                      Button{
                                          text: qsTr("Delete")
                                      }
                                      Button{
                                          text: qsTr("Update")
                                      }
                                  }
                              }
                          }
                      }
              

              Note that i changed Listelement property text -> labelText

              1 Reply Last reply
              1
              • QjayQ Offline
                QjayQ Offline
                Qjay
                wrote on last edited by Qjay
                #7

                @medyakovvit Thanks a lot !!

                Solved !!

                1 Reply Last reply
                0
                • jpnurmiJ Offline
                  jpnurmiJ Offline
                  jpnurmi
                  wrote on last edited by
                  #8

                  Both ApplicationWindow and Page provide header and footer properties that are convenient for placing anything at the top or bottom of the window or a page.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved