import QtQuick 2.0
import QtQuick.Controls 1.1
ApplicationWindow {
visible: true
width: 640
height: 480
property string roleName:"buyer";
property string titleName: "Another Column"
property string strTestColumn : "import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Layouts 1.0; TableViewColumn{id:idTestColumn; role:\""+roleName+"\"; title: \""+titleName+"\" ; width: 200 ; Component.onCompleted: {console.log(\"#\");libraryModel.count}}"
property int ic: 0
ListModel {
id: libraryModel
dynamicRoles: true
Component.onCompleted: {
console.log("hell0---------------------------------0")
append({title: "A Masterpiece" , author: "Gabriel" , pages: 500, mc: "1"})
append({title: "Brilliance" , author: "Jens" , pages: 700, mc: "2"})
append({title: "Outstanding" , author: "Frederik2", pages: 600, mc: "3"})
append({title: "Outstanding2" , author: "Frederik3", pages: 600, mc: "3"})
}
}
TableView{
id:idTable
x: 10
y: 50
width:parent.width
model: libraryModel // Table Data model
TableViewColumn{ role: "title" ; title: "Title" ; width: 100 }
TableViewColumn{ role: "author" ; title: "Author" ; width: 200 }
Component.onCompleted: {
console.log("hell0---------------------------------2");
}
}
function addCloumn(propstr,str){
var ii= 0
//it starts at zero "0"
console.log("hell0---------------------------------1 "+propstr)
for( ii=0; ii < libraryModel.count;ii++)
{
libraryModel.setProperty(ii, propstr, propstr+ii);
console.log(libraryModel.get(ii).propstr + "\n");
}
idTable.addColumn(Qt.createQmlObject(str,idTable,'firstObject'));
idTable.model = null;
idTable.model = libraryModel;
}
Component.onCompleted: {
// addCloumn();
}
//Data model for Table
MouseArea{
id:ma
anchors.fill: parent
onClicked: {
ic++;
var strqml="";
var time = new Date();
if(ic%2==0){
roleName = "buyer"+time.getSeconds();
titleName = "BUYER";
strqml = strTestColumn;
}else{
roleName = "seller"+time.getSeconds();;
titleName = "SELLER";
strqml = strTestColumn;
//addCloumn(roleName,strSecondColumn);
}
addCloumn(roleName,strqml);
}
}
}