#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->dockWidget->setTitleBarWidget(new QWidget());
// Set the number of columns in the tree
ui->treeWidget->setColumnCount(1);
// Add root nodes
addTreeRoot("A");
addTreeRoot("B");
addTreeRoot("C");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addTreeRoot(QString nameItem)
{
QTreeWidgetItem *treeWidgetItem = new QTreeWidgetItem(ui->treeWidget);
treeWidgetItem->setText(0, nameItem);
addTreeChild(treeWidgetItem, nameItem);
}
void MainWindow::addTreeChild(QTreeWidgetItem *parent, QString nameItem)
{
QTreeWidgetItem *treeWidgetItem = new QTreeWidgetItem();
treeWidgetItem->setText(0, nameItem);
parent->addChild(treeWidgetItem);
}