QT学习---TreeWidget的基本操作

一、基本的操作:添加、删除、一些常用信号:

#include "TreeWidget.h"
#include 

TreeWidget::TreeWidget(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	//设置列数和每一列的宽度
	ui.treeWidget->setColumnCount(4);
	ui.treeWidget->setColumnWidth(0,50);
	ui.treeWidget->setColumnWidth(1,100);
	ui.treeWidget->setColumnWidth(2,150);
	ui.treeWidget->setColumnWidth(3,200);

	//设置列的标题
	QStringList labelList;
	labelList.append("zhang");
	labelList.append("li");
	labelList.append("wang");
	labelList.append("zhao");

	ui.treeWidget->setHeaderLabels(labelList);

	//隐藏表头
	//ui.treeWidget->setHeaderHidden(true);

	QIcon icon_folder(":/TableAndTreeWidget/Resources/Save.png");
	QIcon icon_file(":/TableAndTreeWidget/Resources/grab.png");

	// 插入数据
	AddItem("aaa.txt", "2015-06-26 07:59:00", "text file", 1242, icon_file);
	AddItem("bbb.mp4", "2015-06-25 14:51:00", "video file", 98990098, icon_file);
	AddItem("ccc.doc", "2015-06-25 07:34:00", "offic

你可能感兴趣的:(QT)