1

我希望主窗体在显示辅助窗体时禁用 selft。我知道我可以使用this->setEnabled = false;,但我怎么知道辅助表单何时关闭?(重新启用主窗体)。

提前致谢。

4

1 回答 1

1

主要小部件

QChildWidget *child = new QChildWidget();
connect(child,SIGNAL(closed()),this,SLOT(childClosed())); //connect child signal to childClosed slot
child->show(); // show child
this->setEnabled(false); // disable main widget

.
.
.
public QMainWidget::childClosed() // implementation of childClosed slot
{
    this->setEnabled(true);
}

child widget

#include <QCloseEvent>
public QChildWidget: public QWidget
{
.
.
.
protected:
      void closeEvent() // it is called when widget is closed
      {
          emit closed();
      }
signals:
        void closed(); // closed signal
};
于 2012-09-21T05:19:54.940 回答