标题:QML TableView添加列问题
作者:charles_gz
日期:2014-10-14 16:32
内容:
我是在动态的添加TableView的列,name列正常显示了,之后的都为“”,是否不可以这样动态的添加?还是我的使用方法问题希望给予指点 谢谢
#1 [彩阳 10-14 20:17]
这样暂时看不出问题,如果怀疑还有问题,那么就制作一个小的例子,作为附件上传。我来看看。
#2 [toby520 10-16 14:05]
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{
..
#3 回 toby520 的帖子 [charles_gz 11-04 11:49]
toby520:import QtQuick 2.0
import QtQuick.Controls 1.1
ApplicationWindow {
visible: true
width: 640
.......(2014-10-16 14:05)
感谢,