QLayout的removeWidget与QButtonGroup的removeButton

测试:QLayoutremoveWidget会不会把widgetdelete掉。

    QVBoxLayout * v_layout=new QVBoxLayout;
    this->centralWidget()->setLayout(v_layout);
    QPushButton * btn=new QPushButton;
    btn->setText("111");
    v_layout->addWidget(btn);
    v_layout->removeWidget(btn);
    qDebug()<text();
    delete btn;

结果:

"111"

不会!!!

 测试:QButtonGroupremoveButton会不会把QPushButton对象delete掉。

    QButtonGroup * group=new QButtonGroup(this);
    QPushButton *btn=new QPushButton();
    btn->setText("111");
    group->addButton(btn);
    group->removeButton(btn);
    qDebug()<text();

结果:

"111"

不会!!!

你可能感兴趣的:(qt)