Tableview customization
-
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" } }
How to fill whole tableview with table like structure(rectangles) instead of blank space?
-
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.
-
Thanks for reply..
My question is...….
this is my output: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.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
(Done this in paint :P)so how can I do this?
-
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.
-
Thanks for help.
-
Hi @ashajg , can you mark [SOLVED] to the thread title.