/// Tree generation
// Add *one* child
child->setText (0, "texttext");
child
->setBackgroundColor
(0,
QColor(255,
0,
0));
_treeRoot->addChild (child);
// Log the texts of each child. This *should* only print out one line, what it does, it prints out the following:
/**
FATAL (:50) - Child #0, text() == texttext
FATAL (:50) - Child #1, text() == texttext
*/
for ( int l=0; l<_treeRoot->childCount(); l++ )
{
LOG_FATAL
(QString ("Child #%1, text() == %2").
arg(l
).
arg(_treeRoot
->child
(l
)->text
(0)).
toStdWString());
}
// Set tree to view ..
emit updateTreeViewSignal(_treeRoot);
/// .. view code.. called by signal above
{
// _treeWidget is a QTreeWidget*, created by the designer
_treeWidget->insertTopLevelItem (0, model);
}
/// Tree generation
QTreeWidgetItem* _treeRoot = new QTreeWidgetItem (QStringList() << "Head");
// Add *one* child
QTreeWidgetItem* child = new QTreeWidgetItem(_treeRoot);
child->setText (0, "texttext");
child->setBackgroundColor (0, QColor(255,0,0));
_treeRoot->addChild (child);
// Log the texts of each child. This *should* only print out one line, what it does, it prints out the following:
/**
FATAL (:50) - Child #0, text() == texttext
FATAL (:50) - Child #1, text() == texttext
*/
for ( int l=0; l<_treeRoot->childCount(); l++ )
{
LOG_FATAL (QString ("Child #%1, text() == %2").arg(l).arg(_treeRoot->child(l)->text(0)).toStdWString());
}
// Set tree to view ..
emit updateTreeViewSignal(_treeRoot);
/// .. view code.. called by signal above
void onUpdateTreeViewSlot ( QTreeWidgetItem * model )
{
// _treeWidget is a QTreeWidget*, created by the designer
_treeWidget->insertTopLevelItem (0, model);
}
To copy to clipboard, switch view to plain text mode
Bookmarks