LordQt
7th September 2007, 13:15
Hello friends,
after some experiences I´ve make my tree. My target is a dockwidget with a tree like the one in the designers left side. My code is :
QDockWidget *docktree = new QDockWidget(tr("MyTestTree"), this);
docktree->minimumHeight();
docktree->setAutoFillBackground(true);
docktree->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QTreeWidget *testTree = new QTreeWidget(docktree);
testTree->setColumnCount(1);
QStringList headerLabels;
headerLabels << "Label";
testTree->setHeaderLabels(headerLabels);
QTreeWidgetItem* item[10];
item[0] = new QTreeWidgetItem(testTree);
item[0]->setText(0, "Node-One");
for (int i=1; i< 5; ++i)
item[i] = new QTreeWidgetItem(item[0]);
item[1]->setText(0, "a");
item[2]->setText(0, "b");
item[3]->setText(0, "c");
item[4]->setText(0, "d");
item[5] = new QTreeWidgetItem(testTree);
item[5]->setText(0, "Node-Two");
for (int i=6; i< 10; ++i)
item[i] = new QTreeWidgetItem(item[5]);
item[6]->setText(0, "a");
item[7]->setText(0, "b");
item[8]->setText(0, "c");
item[9]->setText(0, "d");
Is there any tips for me to make them nearly looks like the designer one´s??
after some experiences I´ve make my tree. My target is a dockwidget with a tree like the one in the designers left side. My code is :
QDockWidget *docktree = new QDockWidget(tr("MyTestTree"), this);
docktree->minimumHeight();
docktree->setAutoFillBackground(true);
docktree->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QTreeWidget *testTree = new QTreeWidget(docktree);
testTree->setColumnCount(1);
QStringList headerLabels;
headerLabels << "Label";
testTree->setHeaderLabels(headerLabels);
QTreeWidgetItem* item[10];
item[0] = new QTreeWidgetItem(testTree);
item[0]->setText(0, "Node-One");
for (int i=1; i< 5; ++i)
item[i] = new QTreeWidgetItem(item[0]);
item[1]->setText(0, "a");
item[2]->setText(0, "b");
item[3]->setText(0, "c");
item[4]->setText(0, "d");
item[5] = new QTreeWidgetItem(testTree);
item[5]->setText(0, "Node-Two");
for (int i=6; i< 10; ++i)
item[i] = new QTreeWidgetItem(item[5]);
item[6]->setText(0, "a");
item[7]->setText(0, "b");
item[8]->setText(0, "c");
item[9]->setText(0, "d");
Is there any tips for me to make them nearly looks like the designer one´s??