I've created this table view in Qt 5.12 with new TableView
but I don't know how to create header for it, I read documentation there is no headerdelegate for it neither. Here some screenshot:
so how can i add headerDelegate for 5.12 TableView?
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
visible: true
ListModel{
id:tableModel
ListElement{
identifier:1
name:'value'
title: 'test'
}
ListElement{
identifier:2
name:'value2'
title: 'test2'
}
}
width:1000; height: 500
//
TableView {
id:trans
LayoutMirroring.enabled: true
LayoutMirroring.childrenInherit: true
anchors.fill: parent
columnSpacing: 1
rowSpacing: 1
clip: true
model: tableModel
delegate: Rectangle {
Row{
Rectangle{
implicitWidth: 100
implicitHeight: 50
Text{
text: identifier
}
}
Rectangle{
implicitWidth: 100
implicitHeight: 50
Text{
text:name
}
}
Rectangle{
implicitWidth: 100
implicitHeight: 50
Text{
text:title
}
}
}
}
}
}
and TableViewColumn didn't work
Qc.TableViewColumn{
title: 'id'
role: 'identifier'
width:100
}
i'm trying to set its header from c++ but sth is not ok with my code
class TableHelper : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE void setTableHeader(QObject & table){
// get QTableView and Set QHeaderView
qDebug()<< "here";
}
};
main :
TableHelper th;
engine.rootContext()->setContextProperty("tableHelper",&th);
qml :
Component.onCompleted: {
tableHelper.setTableHeader(trans)
}
I have a break point in C++ code, but it never runs.
This github repo shows how to build in your own headers in a QML
TableView
(Qt 5.12.0):