#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "MyStyle.h"
#include <QMultiMap>
QList<QTreeWidgetItem*> lstWidgets;
QList<QTreeWidgetItem*> lstSubItems;
{
ui->setupUi(this);
pTree = NULL;
initTree();
this->resize(size);
this->setMinimumSize(size);
this->setMaximumSize(size);
ui->gridLayout->addWidget(pTree);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::initTree()
{
pTree->setGeometry(10,10,520,850);
pTree->setMaximumSize(520,850);
pTree->show();
lstheadrs.append(" \n \n \n \n \n \n ");
lstheadrs.append("1");
lstheadrs.append("2");
lstheadrs.append("3");
lstheadrs.append("4");
lstheadrs.append("5");
lstheadrs.append("6");
lstheadrs.append("7");
lstheadrs.append("8");
lstheadrs.append("9");
lstheadrs.append("10");
lstheadrs.append("11");
lstheadrs.append("12");
pTree->setHeaderLabels(lstheadrs);
//------SET COLUMN WIDTH---------------
pTree->setColumnWidth(0,190);
for(int i = 1; i<=12; i++)
{
pTree->setColumnWidth(i,25);
}
MyStyle *headerStyl = new MyStyle(this->style());
pTree->setStyle(headerStyl);
//==========================================================================================================//
pTree->expandItem(Node1);
for(int iChild=0; iChild<Node1->childCount() ; iChild++)
for(int i=1; i<lstheadrs.length(); i++)
Node1->child(iChild)->setCheckState(i,Qt::Unchecked);
lstWidgets.append(Node1);
//==========================================================================================================//
pTree->expandItem(Node2);
for(int iChild=0; iChild<Node2->childCount() ; iChild++)
for(int i=1; i<lstheadrs.length(); i++)
Node2->child(iChild)->setCheckState(i,Qt::Unchecked);
lstWidgets.append(Node2);
//==========================================================================================================//
Node3->addChild(node3sub1);
for(int iChild=0; iChild<node3sub1->childCount(); iChild++)
for(int i=1; i<lstheadrs.length(); i++)
node3sub1->child(iChild)->setCheckState(i,Qt::Unchecked);
Node3->addChild(node3sub2);
for(int iChild=0; iChild<node3sub2->childCount(); ++iChild)
for(int i=1; i<lstheadrs.length(); i++)
node3sub2->child(iChild)->setCheckState(i,Qt::Unchecked);
Node3->addChild(node3sub3);
for(int iChild=0; iChild<node3sub3->childCount(); iChild++)
for(int i=1; i<lstheadrs.length(); i++)
node3sub3->child(iChild)->setCheckState(i,Qt::Unchecked);
pTree->expandItem(Node3);
for(int iChild=0; iChild<Node3->childCount() ; iChild++)
for(int i=1; i<lstheadrs.length(); i++)
Node3->child(iChild)->setCheckState(i,Qt::Unchecked);
lstWidgets.append(Node3);
lstWidgets.append(node3sub1);
lstWidgets.append(node3sub2);
lstWidgets.append(node3sub3);
//==========================================================================================================//
pTree->expandItem(node4);
for(int iChild=0; iChild<node4->childCount() ; iChild++)
for(int i=1; i<lstheadrs.length(); i++)
node4->child(iChild)->setCheckState(i,Qt::Unchecked);
lstWidgets.append(node4);
//==========================================================================================================//
pTree->expandItem(node5);
for(int iChild=0; iChild<node5->childCount() ; iChild++)
for(int i=1; i<lstheadrs.length(); i++)
node5->child(iChild)->setCheckState(i,Qt::Unchecked);
lstWidgets.append(node5);
}