1. 示例代码:
void ParamSetting::add_operate_button(QTableWidget *table, int row)
{
QPushButton* delBtn = new QPushButton;
QPushButton* edtBtn = new QPushButton;
QHBoxLayout *h_box_layout = new QHBoxLayout(); //添加水平布局控件
MyProperty myProperty; //自定义类,后面有解释
memset(&myProperty, 0, sizeof(MyProperty));
myProperty.row = row;
myProperty.table = table;
QVariant v;
v.setValue(myProperty);
QWidget *widget = new QWidget(); //添加部件
delBtn->setIcon(QIcon(":/res/button/delete.png"));
delBtn->setToolTip("删除");
delBtn->setProperty("sender", v);
QObject::connect(delBtn, SIGNAL(clicked()), this, SLOT(slot_remove_row())); //设置删除动作槽函数
edtBtn->setIcon(QIcon(":/res/button/edit.png"));
edtBtn->setToolTip("修改");
edtBtn->setProperty("sender", v);
QObject::connect(edtBtn, SIGNAL(clicke