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. Emulating ListView as TableView
QtWS25 Last Chance

Emulating ListView as TableView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlviewlistviewtableview
6 Posts 3 Posters 924 Views
  • 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.
  • A Offline
    A Offline
    Ahti
    wrote on 21 Feb 2020, 09:28 last edited by Ahti
    #1

    I want to do the following with TableView instead of ListView :

    StackView {
            id: home
            anchors.fill: parent
            padding: 0
            property var model: null
    
            initialItem: Pane {
                ColumnLayout {
                        id: body
    
                        ListView {
                            id: view
                            currentIndex: -1
                            height: body.height
                            width: body.width
    
                            delegate: SwipeDelegate {
                                    id: content
                                    width: parent.width
                                    height: 50
                                    text: model.name
                                    swipe.onCompleted: {
                                        if (swipe.position > 0){
                                             home.model = model
                                             home.pop()										 
                                             home.push("Profile.qml")
    					}
                                        swipe.close()
                                    }
    
                                    swipe.left: Label {
                                        text: qsTr("Profile")
                                        color: "white"
                                        verticalAlignment: Label.AlignVCenter
                                        padding: 12
                                        height: parent.height
                                        anchors.left: parent.left
                                        opacity: 2 * content.swipe.position
                                    }
                            }
                            model: UserModel { id: user_model }
    
                            ScrollIndicator.vertical: ScrollIndicator {}
                        }
                    }
    	      }				
          }
    

    How could I do it ?

    what is a signature ?? Lol

    A R 2 Replies Last reply 27 Feb 2020, 17:04
    0
    • A Ahti
      21 Feb 2020, 09:28

      I want to do the following with TableView instead of ListView :

      StackView {
              id: home
              anchors.fill: parent
              padding: 0
              property var model: null
      
              initialItem: Pane {
                  ColumnLayout {
                          id: body
      
                          ListView {
                              id: view
                              currentIndex: -1
                              height: body.height
                              width: body.width
      
                              delegate: SwipeDelegate {
                                      id: content
                                      width: parent.width
                                      height: 50
                                      text: model.name
                                      swipe.onCompleted: {
                                          if (swipe.position > 0){
                                               home.model = model
                                               home.pop()										 
                                               home.push("Profile.qml")
      					}
                                          swipe.close()
                                      }
      
                                      swipe.left: Label {
                                          text: qsTr("Profile")
                                          color: "white"
                                          verticalAlignment: Label.AlignVCenter
                                          padding: 12
                                          height: parent.height
                                          anchors.left: parent.left
                                          opacity: 2 * content.swipe.position
                                      }
                              }
                              model: UserModel { id: user_model }
      
                              ScrollIndicator.vertical: ScrollIndicator {}
                          }
                      }
      	      }				
            }
      

      How could I do it ?

      A Offline
      A Offline
      Ahti
      wrote on 27 Feb 2020, 17:04 last edited by Ahti
      #2

      @GrecKo can you please answer this...

      what is a signature ?? Lol

      1 Reply Last reply
      0
      • A Ahti
        21 Feb 2020, 09:28

        I want to do the following with TableView instead of ListView :

        StackView {
                id: home
                anchors.fill: parent
                padding: 0
                property var model: null
        
                initialItem: Pane {
                    ColumnLayout {
                            id: body
        
                            ListView {
                                id: view
                                currentIndex: -1
                                height: body.height
                                width: body.width
        
                                delegate: SwipeDelegate {
                                        id: content
                                        width: parent.width
                                        height: 50
                                        text: model.name
                                        swipe.onCompleted: {
                                            if (swipe.position > 0){
                                                 home.model = model
                                                 home.pop()										 
                                                 home.push("Profile.qml")
        					}
                                            swipe.close()
                                        }
        
                                        swipe.left: Label {
                                            text: qsTr("Profile")
                                            color: "white"
                                            verticalAlignment: Label.AlignVCenter
                                            padding: 12
                                            height: parent.height
                                            anchors.left: parent.left
                                            opacity: 2 * content.swipe.position
                                        }
                                }
                                model: UserModel { id: user_model }
        
                                ScrollIndicator.vertical: ScrollIndicator {}
                            }
                        }
        	      }				
              }
        

        How could I do it ?

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 27 Feb 2020, 17:42 last edited by raven-worx
        #3

        @Ahti said in Emulating ListView as TableView:

        I want to do the following

        what exactly? swipe the whole table row? if so it wont work, since each cell has it's own delegate

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        A 1 Reply Last reply 27 Feb 2020, 17:53
        0
        • R raven-worx
          27 Feb 2020, 17:42

          @Ahti said in Emulating ListView as TableView:

          I want to do the following

          what exactly? swipe the whole table row? if so it wont work, since each cell has it's own delegate

          A Offline
          A Offline
          Ahti
          wrote on 27 Feb 2020, 17:53 last edited by
          #4

          @raven-worx I just want to display the first column and hide all the other columns... This first column should be swipable.

          what is a signature ?? Lol

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on 27 Feb 2020, 20:15 last edited by
            #5

            Would something like this work:

            itemDelegate: styleData.column == 0 ? SwipeDelegate {} : Item {}
            

            Of course you will have to determine how the SwipeDelegate and Item are constructed. Maybe need to use a Loader somehow and specify the source using the column info for the cell.

            C++ is a perfectly valid school of magic.

            A 1 Reply Last reply 28 Feb 2020, 06:29
            0
            • fcarneyF fcarney
              27 Feb 2020, 20:15

              Would something like this work:

              itemDelegate: styleData.column == 0 ? SwipeDelegate {} : Item {}
              

              Of course you will have to determine how the SwipeDelegate and Item are constructed. Maybe need to use a Loader somehow and specify the source using the column info for the cell.

              A Offline
              A Offline
              Ahti
              wrote on 28 Feb 2020, 06:29 last edited by Ahti
              #6

              @fcarney I am new to Qt so don't anything about Loader and Can you please take a look at this question too: https://forum.qt.io/topic/111852/inconsistency-between-model-and-view-while-updating-qsqltablemodel-cell

              what is a signature ?? Lol

              1 Reply Last reply
              0

              1/6

              21 Feb 2020, 09:28

              • Login

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