个人感觉 QT treeWidget 是VB6里的listview和treeview的合体 应该我会经常用的,做个简单的记录
ui->treeWidget->setHeaderLabels(QStringList() << "资产编号" << "资产名称" << "使用人" ); QTreeWidgetItem * liitem =new QTreeWidgetItem(QStringList()<< "A0001" << "电脑" << "jinesc"); ui->treeWidget->addTopLevelItem(liitem); for (int i=0;i<=10;i++) { QTreeWidgetItem * item =new QTreeWidgetItem(QStringList()<< QString::number(i) ); ui->treeWidget->addTopLevelItem(item); for (int t=0;t<=10;t++) { QStringList child; child << QString::number(t); //数字转字符 child << "电脑" ; child << "jinesc"; QTreeWidgetItem * citem =new QTreeWidgetItem(child); item->addChild(citem); for (int z=0;z<5;z++) { QStringList zchild; zchild << QString::number(z); //数字转字符 QTreeWidgetItem * zitem =new QTreeWidgetItem(zchild); citem->addChild(zitem); } } }
运行如图:
发表评论