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. How to add a header for QtQuick TableView in Qt-5.12?
Forum Updated to NodeBB v4.3 + New Features

How to add a header for QtQuick TableView in Qt-5.12?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 1.1k Views 2 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    Is there a best way to do this? There is one video on youtube but the header is not sticky at the top. There are some entries on this forum but none are really sufficient. Is this seven technically possible? If not, then woah.

    https://alaskafamilysystems.com/

    1 Reply Last reply
    0
    • C Offline
      C Offline
      closx
      wrote on last edited by closx
      #2

      Hi!
      I couldn't understand what exactly you want. But maybe something like this would work?

      TableView {
          TableViewColumn {
              role: "header1"
              title: "Header 1"
              width: 100
          }
          TableViewColumn {
              role: "header2"
              title: "Header 2"
              width: 200
          }
          TableViewColumn {
              role: "header3"
              title: "Header 4"
              width: 300
          }
          model: myModel
      }
      
      ListModel {
          id: myModel
          ListElement {
              header1: "header1 text 1"
              header2: "header2 text 1"
              header3: "header3 text 1"
          }
          ListElement {
              header1: "header1 text 2"
              header2: "header2 text 2"
              header3: "header3 text 2"
          }
          ListElement {
              header1: "header1 text 3"
              header2: "header2 text 3"
              header3: "header3 text 3"
          }
          ListElement {
              header1: "header1 text 4"
              header2: "header2 text 4"
              header3: "header3 text 4"
          }
      }
      

      Maybe you can describe your needs in a more spesific way :D

      bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
      tag me (like @closx) if you are answering to me, so I can notice :D

      P 1 Reply Last reply
      0
      • C closx

        Hi!
        I couldn't understand what exactly you want. But maybe something like this would work?

        TableView {
            TableViewColumn {
                role: "header1"
                title: "Header 1"
                width: 100
            }
            TableViewColumn {
                role: "header2"
                title: "Header 2"
                width: 200
            }
            TableViewColumn {
                role: "header3"
                title: "Header 4"
                width: 300
            }
            model: myModel
        }
        
        ListModel {
            id: myModel
            ListElement {
                header1: "header1 text 1"
                header2: "header2 text 1"
                header3: "header3 text 1"
            }
            ListElement {
                header1: "header1 text 2"
                header2: "header2 text 2"
                header3: "header3 text 2"
            }
            ListElement {
                header1: "header1 text 3"
                header2: "header2 text 3"
                header3: "header3 text 3"
            }
            ListElement {
                header1: "header1 text 4"
                header2: "header2 text 4"
                header3: "header3 text 4"
            }
        }
        

        Maybe you can describe your needs in a more spesific way :D

        P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        @closx said in How to add a header for QtQuick TableView in Qt-5.12?:

        Hi!
        I couldn't understand what exactly you want. But maybe something like this would work?

        TableView {
            TableViewColumn {
                role: "header1"
                title: "Header 1"
                width: 100
            }
            TableViewColumn {
                role: "header2"
                title: "Header 2"
                width: 200
            }
            TableViewColumn {
                role: "header3"
                title: "Header 4"
                width: 300
            }
            model: myModel
        }
        
        ListModel {
            id: myModel
            ListElement {
                header1: "header1 text 1"
                header2: "header2 text 1"
                header3: "header3 text 1"
            }
            ListElement {
                header1: "header1 text 2"
                header2: "header2 text 2"
                header3: "header3 text 2"
            }
            ListElement {
                header1: "header1 text 3"
                header2: "header2 text 3"
                header3: "header3 text 3"
            }
            ListElement {
                header1: "header1 text 4"
                header2: "header2 text 4"
                header3: "header3 text 4"
            }
        }
        

        Maybe you can describe your needs in a more spesific way :D

        I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

        https://alaskafamilysystems.com/

        J.HilkJ C raven-worxR 3 Replies Last reply
        0
        • P patrickkidd

          @closx said in How to add a header for QtQuick TableView in Qt-5.12?:

          Hi!
          I couldn't understand what exactly you want. But maybe something like this would work?

          TableView {
              TableViewColumn {
                  role: "header1"
                  title: "Header 1"
                  width: 100
              }
              TableViewColumn {
                  role: "header2"
                  title: "Header 2"
                  width: 200
              }
              TableViewColumn {
                  role: "header3"
                  title: "Header 4"
                  width: 300
              }
              model: myModel
          }
          
          ListModel {
              id: myModel
              ListElement {
                  header1: "header1 text 1"
                  header2: "header2 text 1"
                  header3: "header3 text 1"
              }
              ListElement {
                  header1: "header1 text 2"
                  header2: "header2 text 2"
                  header3: "header3 text 2"
              }
              ListElement {
                  header1: "header1 text 3"
                  header2: "header2 text 3"
                  header3: "header3 text 3"
              }
              ListElement {
                  header1: "header1 text 4"
                  header2: "header2 text 4"
                  header3: "header3 text 4"
              }
          }
          

          Maybe you can describe your needs in a more spesific way :D

          I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @patrickkidd
          you don't,

          The QuickControlls 2 TableView is very very new. It came with 5.12 and is still work in progress.

          Maybe 5.13 adds something? I haven't check yet.

          You'll have to create your own header component, unfortunately


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • P patrickkidd

            @closx said in How to add a header for QtQuick TableView in Qt-5.12?:

            Hi!
            I couldn't understand what exactly you want. But maybe something like this would work?

            TableView {
                TableViewColumn {
                    role: "header1"
                    title: "Header 1"
                    width: 100
                }
                TableViewColumn {
                    role: "header2"
                    title: "Header 2"
                    width: 200
                }
                TableViewColumn {
                    role: "header3"
                    title: "Header 4"
                    width: 300
                }
                model: myModel
            }
            
            ListModel {
                id: myModel
                ListElement {
                    header1: "header1 text 1"
                    header2: "header2 text 1"
                    header3: "header3 text 1"
                }
                ListElement {
                    header1: "header1 text 2"
                    header2: "header2 text 2"
                    header3: "header3 text 2"
                }
                ListElement {
                    header1: "header1 text 3"
                    header2: "header2 text 3"
                    header3: "header3 text 3"
                }
                ListElement {
                    header1: "header1 text 4"
                    header2: "header2 text 4"
                    header3: "header3 text 4"
                }
            }
            

            Maybe you can describe your needs in a more spesific way :D

            I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

            C Offline
            C Offline
            closx
            wrote on last edited by
            #5

            @patrickkidd said in How to add a header for QtQuick TableView in Qt-5.12?:

            I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

            Oh, I have just learned about it :D
            Good work!

            bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
            tag me (like @closx) if you are answering to me, so I can notice :D

            1 Reply Last reply
            0
            • P patrickkidd

              @closx said in How to add a header for QtQuick TableView in Qt-5.12?:

              Hi!
              I couldn't understand what exactly you want. But maybe something like this would work?

              TableView {
                  TableViewColumn {
                      role: "header1"
                      title: "Header 1"
                      width: 100
                  }
                  TableViewColumn {
                      role: "header2"
                      title: "Header 2"
                      width: 200
                  }
                  TableViewColumn {
                      role: "header3"
                      title: "Header 4"
                      width: 300
                  }
                  model: myModel
              }
              
              ListModel {
                  id: myModel
                  ListElement {
                      header1: "header1 text 1"
                      header2: "header2 text 1"
                      header3: "header3 text 1"
                  }
                  ListElement {
                      header1: "header1 text 2"
                      header2: "header2 text 2"
                      header3: "header3 text 2"
                  }
                  ListElement {
                      header1: "header1 text 3"
                      header2: "header2 text 3"
                      header3: "header3 text 3"
                  }
                  ListElement {
                      header1: "header1 text 4"
                      header2: "header2 text 4"
                      header3: "header3 text 4"
                  }
              }
              

              Maybe you can describe your needs in a more spesific way :D

              I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @patrickkidd said in How to add a header for QtQuick TableView in Qt-5.12?:

              I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

              https://blog.qt.io/blog/2018/08/29/tableview/

              Other than this, the API for the first release of TableView is kept pretty small and strict. More will be implemented later, such as using custom transitions when adding or removing rows and columns. We’re also working on a TableHeader, TableModel, as well as a DelegateChooser. The latter lets you assign several delegates to a TableView, and e.g use a different one for each column. The latter will already be available in Qt 5.12 as a labs import (Qt.labs.qmlmodels 1.0).

              --- 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

              P 1 Reply Last reply
              2
              • raven-worxR raven-worx

                @patrickkidd said in How to add a header for QtQuick TableView in Qt-5.12?:

                I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

                https://blog.qt.io/blog/2018/08/29/tableview/

                Other than this, the API for the first release of TableView is kept pretty small and strict. More will be implemented later, such as using custom transitions when adding or removing rows and columns. We’re also working on a TableHeader, TableModel, as well as a DelegateChooser. The latter lets you assign several delegates to a TableView, and e.g use a different one for each column. The latter will already be available in Qt 5.12 as a labs import (Qt.labs.qmlmodels 1.0).

                P Offline
                P Offline
                patrickkidd
                wrote on last edited by
                #7

                @raven-worx said in How to add a header for QtQuick TableView in Qt-5.12?:

                @patrickkidd said in How to add a header for QtQuick TableView in Qt-5.12?:

                I am not asking about the TableView from QtQuick.Controls but the new QtQuick TableView. The question is straightforward considering that - how to add a header that works like the header in QTableView.

                https://blog.qt.io/blog/2018/08/29/tableview/

                Other than this, the API for the first release of TableView is kept pretty small and strict. More will be implemented later, such as using custom transitions when adding or removing rows and columns. We’re also working on a TableHeader, TableModel, as well as a DelegateChooser. The latter lets you assign several delegates to a TableView, and e.g use a different one for each column. The latter will already be available in Qt 5.12 as a labs import (Qt.labs.qmlmodels 1.0).

                Thanks for the tip. Will there be a way to draw certain columns in a custom manner, like the following question: https://forum.qt.io/topic/104441/custom-painting-in-listview-along-many-rows/2

                https://alaskafamilysystems.com/

                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