Header in QML column -
i have piece of code in qml, i'm not able add static text header of each column.
i tried looking online don't seem find asnwer. or don't it.
component { id: pedido item { id: item width: parent.width; row { id: row width: parent.width anchors.verticalcenter: parent.verticalcenter column { width: parent.width * 0.3 text { text: " " + codigo; font.family: "helvetica" font.pointsize: 14 font.bold: true color: item.listview.iscurrentitem ? "white" : "black" } column { width: parent.width * 0.5 text { text: " " + nombre; font.family: "helvetica" font.pointsize: 14 font.bold: true color: item.listview.iscurrentitem ? "white" : "black" } } column { width: parent.width * 0.2 text { text: " " + fecha; font.family: "helvetica" font.pointsize: 14 font.bold: true } }
don't worry if there missing {}
.
you should implement own header
. more info in documentation.
let me show example simple listmodel
& listview
:
import qtquick 2.5 import qtquick.window 2.2 window { visible: true width: 500 height: 500 rectangle { width: 300 height: 400 component { id: listdelegate item { width: 400; height: 50; row { column { width: 100 text { text: codigo } } column { width: 100 text { text: nombre } } column { width: 100 text { text: fecha } } } } } listmodel { id: listmodel listelement { codigo: "111" nombre: "aaa" fecha: "28/08/2001" } listelement { codigo: "222" nombre: "bbb" fecha: "28/08/2002" } listelement { codigo: "333" nombre: "ccc" fecha: "28/08/2003" } } listview { id: listview anchors.fill: parent model: listmodel delegate: listdelegate focus: true header: myheader } } component { //instantiated when header processed id: myheader rectangle { gradient: mygradient border {color: "#9eddf2"; width: 2} width: parent.width; height: 50 row { column { width: 100 text { text: "codigo" } } column { width: 100 text { text: "nombre" } } column { width: 100 text { text: "fecha" } } } } } gradient { id: mygradient gradientstop { position: 0.0; color: "#8ee2fe"} gradientstop { position: 0.66; color: "#7ed2ee"} } }
Comments
Post a Comment