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. Tableview customization
Forum Updated to NodeBB v4.3 + New Features

Tableview customization

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 751 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.
  • ashajgA Offline
    ashajgA Offline
    ashajg
    wrote on last edited by ashajg
    #1

    hi guys

    I am implementing tableview

    code:

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.0
    import QtQuick.Controls 1.4
    
        Rectangle{id:maint
            anchors.fill:parent
            color:"lightcyan"
            height:500
            width:600
            Rectangle{
                id:frame
                height:600
                width:700
                TableView {
                    height: 500
                    width:500
                    anchors.fill:parent
    
                    TableViewColumn {
                        role: "time"
                        title: "Time"
                        movable: false
                        resizable: false
                        width: 500
    
                    }
                    TableViewColumn {
                        role: "type"
                        title: "Type"
                        movable: false
                        resizable: false
                        width:100
                    }
    
                    TableViewColumn {
                        role: "message"
                        title: "Message"
                        movable: false
                        resizable: false
                        width:350
                    }
                    model: modelTab
                    itemDelegate: Item {
                        Rectangle
                        {color: "white"
                            anchors.fill:parent
                            border.color: "black"
                            Text {
                                id: jkl
                                anchors.fill:parent
                                text:styleData.value
    
                            }
                        }
                    }
    
                rowDelegate: rower
    
                    Component
                    {
                        id:rower
                        Rectangle
                        {
                            border.color: "black"
                            //color:"blue"
                            anchors.fill:parent
                        }
                    }
                }
    
                ModelTable
                {
                    id:modelTab
                }
            }
        }
    

    ////////////////////////////////////////////////////////////////

    import QtQuick 2.0
    
    ListModel {
        id: libraryModel
            ListElement {
                time: "31-Oct-2018 11:34 "
                type: "Event"
                message: "Standby mode"
    
            }
            ListElement {
                time: "31-Oct-2018 11:34 "
                type: "Alarm"
                message:"System On"
            }
            ListElement {
                time: "31-Oct-2018 11:34 "
                type: "Event"
                message:"System On"
            }
            ListElement {
                time: "31-Oct-2018 11:34 "
                type: "Event"
                message:"Service mode"
            }
            ListElement {
                time: "31-Oct-2018 11:34 "
                type: "Alarm"
                message:"Service mode"
            }
    }
    

    0_1552651502519_a36b9e0b-fc4a-48df-aa3b-ab2758f47d3a-image.png

    How to fill whole tableview with table like structure(rectangles) instead of blank space?

    1 Reply Last reply
    0
    • Shrinidhi UpadhyayaS Offline
      Shrinidhi UpadhyayaS Offline
      Shrinidhi Upadhyaya
      wrote on last edited by
      #2

      Hi @ashajg ,

      first thing is to remove the anchors.fill: parent from TableView

      TableView {
                  height: parent.height
                  width: parent.width
                   //####Remove the below line
                  //anchors.fill: parent
      }
      

      Next thing is if you know the height of the screen, you can directly hardcode it, which i dont recommend,otherwise you can directly assign the screen height

      TableView {
                  height: Screen.height
                  width: Screen.width
                   //####Remove the below line
                  //anchors.fill: parent
      }
      

      The above code with fill the complete screen.

      I dont know,but its weird that TableView fills its height and width with respect to the height and width of the Screen when its first launched.And the anchors.fill also does not work.

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      1 Reply Last reply
      0
      • ashajgA Offline
        ashajgA Offline
        ashajg
        wrote on last edited by
        #3

        hi @Shrinidhi-Upadhyaya

        Thanks for reply..
        My question is...….
        this is my output:

        0_1552902920243_936def7f-d4ef-4065-a4b6-8a59976b6c19-image.png

        Here we have 5 entries as I am using itemDelegate as rectangle I am getting cell kind of structure for first 5 entries
        but after five entries I am getting an alternate color pattern thing. I have attached image below.

        0_1552903165543_34bd22b7-3fb7-46ef-8150-924ad0e16519-image.png

        I donot want this pattern I want to continue that cell kind of pattern even if their are no entries.

        I want something like this

        0_1552903610925_8b7e8299-2ac7-4557-a125-90d2c7cfc303-image.png
        (Done this in paint :P)

        so how can I do this?

        1 Reply Last reply
        0
        • Shrinidhi UpadhyayaS Offline
          Shrinidhi UpadhyayaS Offline
          Shrinidhi Upadhyaya
          wrote on last edited by
          #4

          Hi @ashajg , then i guess you need to use the latest TableView that is you need to use Qt 5.12 so that you would be able to use QtQuick 2.12. It seems to be more efficient and easy to handle as compared to the one you are using,not explored completely though.

          Shrinidhi Upadhyaya.
          Upvote the answer(s) that helped you to solve the issue.

          1 Reply Last reply
          2
          • ashajgA Offline
            ashajgA Offline
            ashajg
            wrote on last edited by
            #5

            Ok @Shrinidhi-Upadhyaya

            Thanks for help.

            1 Reply Last reply
            0
            • Shrinidhi UpadhyayaS Offline
              Shrinidhi UpadhyayaS Offline
              Shrinidhi Upadhyaya
              wrote on last edited by
              #6

              Hi @ashajg , can you mark [SOLVED] to the thread title.

              Shrinidhi Upadhyaya.
              Upvote the answer(s) that helped you to solve the issue.

              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