QtreeWidget QtreeWidget
作者:互联网
ui->treeWidget->setColumnCount(1); //设置列数
ui->treeWidget->setHeaderLabel(tr("构件选择")); //设置头的标题
ui->treeWidget->setHeaderHidden(true);//隐藏表头
QPalette p(ui->treeWidget->palette());//设置背景色
p.setColor(QPalette::Base, QColor("#ced9e6"));
ui->treeWidget->setPalette(p);
QTreeWidgetItem *imageItem1 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("主构件")));
imageItem1->setBackgroundColor(0,QColor("#e5ebf4"));//设置背景颜色
QTreeWidgetItem *imageItem1_1 = new QTreeWidgetItem(imageItem1,QStringList(QString("钢柱"))); //子节点1
QTreeWidgetItem *imageItem1_2 = new QTreeWidgetItem(imageItem1,QStringList(QString("钢梁"))); //子节点2
QTreeWidgetItem *imageItem1_3 = new QTreeWidgetItem(
标签:QtreeWidget,imageItem1,QStringList,QTreeWidgetItem,ui,treeWidget,new 来源: https://blog.csdn.net/tony2278/article/details/104535953