Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

qml TableView dynamic

Component{
    id: columnComponent
    TableViewColumn{width: 30 }
}

TableView {
    id: tableView
    model: listModel
    property var titles: somethingDynamic
    property var curTitles: {
        var t=[]
        for(var i=0;i<columnCount;i++){
            t.push(getColumn(i).title)
        }
        return t
    }
    onTitlesChanged:{
        for(var i=0;i<titles.length;i++){
            if(curTitles.indexOf(titles[i])==-1){
                var column = addColumn(columnComponent) 
                column.title=titles[i]
                column.role=titles[i]                   
            }
        }
        for(var i=curTitles.length-1;i>=0;i--){
            if(titles.indexOf(curTitles[i])==-1){
                removeColumn(i)
            }
        }
    }
}
Comment

qml tableview dynamic

Component
{
    id: columnComponent
    TableViewColumn{width: 100 }
}

TableView {
    id: view
    anchors.fill: parent
    resources:
    {
        var roleList = myModel.customRoleNames
        var temp = []
        for(var i=0; i<roleList.length; i++)
        {
            var role  = roleList[i]
            temp.push(columnComponent.createObject(view, { "role": role, "title": role}))
        }
        return temp
    }

    model: myModel
Comment

PREVIOUS NEXT
Code Example
Typescript :: keynote Invite multiple users to make edits to the same document: 
Typescript :: Local Variable in Jenkins 
Typescript :: use curly brackets in latex 
Typescript :: best way to convert string to number typescript 
Typescript :: four basic components that information system consists of 
Typescript :: site:community.nxp.com dts gpio output high active 
Typescript :: TypeScript interface for object with arbitrary numeric property names? 
Typescript :: how to delete a struct in a arra of strcts c 
Typescript :: jest aliases typescript storybook 
Typescript :: graphql?query={__schema{types{name,fields{name}}}} 
Typescript :: custom function with condition in google sheet 
Typescript :: reader.readasarraybuffer(file) is undefined 
Typescript :: bibtex remove brackets in note field 
Typescript :: typescript reduce initial value type 
Typescript :: middleware in endpoint controller routing-controllers 
Typescript :: tkinter widgets overview 
Typescript :: stratford school academy 
Typescript :: Laravel 8 working with subdomain routing but its not working 
Typescript :: 3 dots for edit bootstrap 
Typescript :: typescript enum includes value 
Typescript :: embed python in html 
Typescript :: print diagonal elements of matrix in c 
Typescript :: python write a program that asks the user for a weight in kilograms and converts it to pounds 
Cpp :: c++ clear console 
Cpp :: flutter margins 
Cpp :: how to print in c++ 
Cpp :: set platformio to C++17 
Cpp :: c++ custom compare in set 
Cpp :: eosio parse string 
Cpp :: is there an algorithm to create a truly random password 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =