父窗体与子窗体各自的代码如下:

 

1、  父窗体的代码:

void FartherWindow::addactions()

{

    SubWindow subwindow(this); // 把父窗体本身this当成参数传到子窗体

    subwindow.clearWindow(); // clearWindow()是子窗体的public方法

    subwindow.exec();

}

 

 

 

2、  子窗体的代码:

 

// closeEvent()是子窗体按下关闭按钮时触发的事件,我在这里重写了它

void SubWindow::closeEvent(QCloseEvent *) 
{
     FartherWindow *fartherwindow = (FartherWindow *)parentWidget();   
     if(fartherwindow != NULL)   
     {      
        //cleartableview()是父窗体的public方法,用于刷新tableview控件 

        fartherwindow ->createtableview(); 
      }
}

 

posted on 2014-01-08 17:21  guolebin7  阅读(3099)  评论(0编辑  收藏  举报