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 925 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.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on 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

    AhtiA raven-worxR 2 Replies Last reply
    0
    • AhtiA Ahti

      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 ?

      AhtiA Offline
      AhtiA Offline
      Ahti
      wrote on last edited by Ahti
      #2

      @GrecKo can you please answer this...

      what is a signature ?? Lol

      1 Reply Last reply
      0
      • AhtiA Ahti

        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 ?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on 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

        AhtiA 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @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

          AhtiA Offline
          AhtiA Offline
          Ahti
          wrote on 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 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.

            AhtiA 1 Reply Last reply
            0
            • fcarneyF fcarney

              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.

              AhtiA Offline
              AhtiA Offline
              Ahti
              wrote on 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

              • Login

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