Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我应该这样做:
auto btnDelete = new QPushButton(this); btnDelete->setText("Delete");
或者这样做是否安全:
auto btnDelete = new QPushButton("Delete");
为什么?
我添加它:this->ui->formLayout->addRow(btnDelete, editForm);
this->ui->formLayout->addRow(btnDelete, editForm);
这是完全安全的。将其添加到布局的那一刻,布局将为您设置父级。对于布局所有者的任何小部件。删除父级的那一刻,它还将调用按钮的解构器