Untitled-1.jpg
We need to display some contents (some text and symbols)below the Wit Name
sample code is below:
for(int i=0; i<3; i++)
{
ui->firstTreeWidget->addTopLevelItem(parent);
parent
->setIcon
( 0,
QPixmap::fromImage( QImage("images/heart.png") ) );
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->firstTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->firstTreeWidget
));
}
for(int i=0; i<1; i++)
{
ui->secTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->secTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->secTreeWidget
));
}
for(int i=0; i<5; i++)
{
ui->thirdTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->thirdTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->thirdTreeWidget
));
}
for(int i=0; i<3; i++)
{
QStringList strings;
strings << QString("Wit Name");
QTreeWidgetItem *parent = new QTreeWidgetItem(strings);
ui->firstTreeWidget->addTopLevelItem(parent);
parent->setIcon( 0, QPixmap::fromImage( QImage("images/heart.png") ) );
// Add the child TreeWidgetItem one step down in the tree
QTreeWidgetItem *child = new QTreeWidgetItem();
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui->firstTreeWidget->setItemWidget(child, 0, new QLabel(ui->firstTreeWidget));
}
for(int i=0; i<1; i++)
{
QStringList strings;
strings << QString("Wit Name");
QTreeWidgetItem *parent = new QTreeWidgetItem(strings);
ui->secTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
QTreeWidgetItem *child = new QTreeWidgetItem;
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui->secTreeWidget->setItemWidget(child, 0, new QLabel(ui->secTreeWidget));
}
for(int i=0; i<5; i++)
{
QStringList strings;
strings << QString("Wit Name");
QTreeWidgetItem *parent = new QTreeWidgetItem(strings);
ui->thirdTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
QTreeWidgetItem *child = new QTreeWidgetItem;
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui->thirdTreeWidget->setItemWidget(child, 0, new QLabel(ui->thirdTreeWidget));
}
To copy to clipboard, switch view to plain text mode
Bookmarks