My problem is that I need to read the names and number of columns in the table from one array (tFields), and the element data from the second array (tRecords).
I have already implemented the reading and creation of columns, I ask you to help or tell me where the problem is in creating the list.
Here is the code:
function buildColumns() {
var rc = vConnection.recCount
var fc = vConnection.fldCount
for(var i = 0; i < fc; ++i)
{
var str = 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Layouts 1.0; TableViewColumn{ id: idColumn; role: '
str += '"' + vConnection.tFields[i] + '"' + '; title: ' + '"' + vConnection.tFields[i] + '"' + '; width: ' + (tblPage.width / vConnection.fldCount) +'; Component.onCompleted: console.log("YEY");}'
tbl.addColumn(Qt.createQmlObject(str, tbl))
}
for(var j = 0; j < rc; ++j)
{
var str2 = 'import QtQuick 2.12; import QtQuick.Window 2.12; import QtQuick.Controls 2.4; import QtQuick.Controls.Imagine 2.3; import QtQuick.Templates 2.5; import QtQuick.Controls 1.4; ListElement { id: idColumn; '
for(var f = 0; f < fc; ++f)
{
str2 += vConnection.tFields[f] + ': "' + vConnection.tRecords[f + rc] + '"; '
}
str2 += '}'
Qt.createQmlObject(str2, lmTable)
}
}
Component.onCompleted: {
buildColumns();
}
TableView {
id: tbl
anchors.fill: parent
model: ListModel {
id: lmTable
}
}
}