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 make a TableView static
Forum Updated to NodeBB v4.3 + New Features

How to make a TableView static

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 3 Posters 784 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.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

    I am having some trouble making a 'TableView' static. I have already set:

          verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
          selectionMode: SelectionMode.NoSelection
    

    yet you can still scroll in the view. Is there a way to prevent the user from being able to interact with a TableView?

    Note: Also the TableViewColumn resizable and moveable properties have been set to false.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      QtQuick 2 version of TableView is based upon a Flickable. So set interactive to false.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        Tried flickableItem.interactive: false but I am still able to scroll through the TableView. I imagine this has something to do with the fact that the view doesn't have a static height property set. I tried setting one:

        height: contentItem.childrenRect.height
        

        which does prevent the table from being scroll-able but that gives me a recursive binding error:
        "QML TableView: Binding loop detected for property "height"

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          Just set interactive: false. Its a property of the TableView. You can do a delayed binding by doing the Binding {} item. That might help with the binding loop.

          C++ is a perfectly valid school of magic.

          C 1 Reply Last reply
          0
          • fcarneyF fcarney

            Just set interactive: false. Its a property of the TableView. You can do a delayed binding by doing the Binding {} item. That might help with the binding loop.

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

            @fcarney interactive doesn't seem to be a property of TableView. That delayed binding might work, any idea what my when property would be?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Do you mean you want to disable it ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Do you mean you want to disable it ?

                C Offline
                C Offline
                Circuits
                wrote on last edited by Circuits
                #7

                @SGaist It's all a bit hard to explain what I want and why but I will try. Essentially, I only want my header text to be visible:

                      headerDelegate: Rectangle
                      {
                        color: "transparent"
                        implicitHeight: _headerTxt.paintedHeight
                        anchors.margins: 10
                        Text
                        {
                          id: _headerTxt
                          font: fontStyle.font
                          color: fontStyle.color
                          text: styleData.value
                        }
                      }
                

                however, this was causing an issue with overlapping text in the header:

                problemText.png

                So I thought if I could make the view static s/t the user can not scroll through it and then determine the height of the view at runtime then problem solved. This required me to set the height:

                    TableView
                    {
                      id: _sectionDetails
                      anchors.margins: 10
                      width: parent.width
                      height: contentItem.childrenRect.height
                ...
                

                but that caused a property binding error. So now I am trying to figure out how to use a delayed binding s/t I do not get the error but even if that works the view still seems scroll-able... (or maybe not scroll-able but more like flick-able) even with a static height value set and:

                verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
                selectionMode: SelectionMode.NoSelection
                flickableItem.interactive: false
                

                also the TableView columns themselves have their resizable and moveable properties set to false.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Circuits
                  wrote on last edited by
                  #8

                  You know what would solve my problem. If I could somehow make the width of the header be dependent upon the number of columns so that it's not twice as long as seen here:

                  newProb.png

                  it may need to be that long when their are more columns coming in from the model but when theirs only two it shouldn't take up the whole page.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Circuits
                    wrote on last edited by
                    #9

                    Not sure why but setting the TableView:

                    width: contentItem.childrenRect.width
                    

                    works just fine with no binding loop errors. This will work for me. I will close this topic.

                    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