1. 添加两个按钮到树形控件,一个编辑按钮,一个删除按钮:
QPushButton *editBtn=new QPushButton;
connect(editBtn, SIGNAL(clicked()), this, SLOT(slot_onClickModify()));
QPushButton *deleteBtn=new QPushButton();
connect(deleteBtn, SIGNAL(clicked()), this, SLOT(slot_onClickDel()));
QHBoxLayout *editLayout=new QHBoxLayout;
editLayout->addWidget(editBtn);
editLayout->addWidget(deleteBtn);
editLayout->addStretch();
QWidget *edit=new QWidget;
edit->setLayout(editLayout);
m_treeShipPlan->addTopLevelItem(node);
//放addTopLevelItem()后才能添加成功
m_treeShipPlan->setItemWidget(node,nFlag++,edit);
2. 点击按钮时的槽函数
void CMyDialog::slot_onClickModify()
{
QP