我正在处理一段代码,我不能 100% 确定它的正确性。请问您能告诉我您对此有何看法吗?(我在 Qt 中编码)
只有一个样本:
CustomWidget *widget; //defined as private
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
widget = new CustomWidget(this);
connect(widget,SIGNAL(onCLose(), this, SLOT(onWidgetClose()));
void onWidgetClose(){
CustomWidget *w = findClosedWidget();
delete w;
}