zoukankan      html  css  js  c++  java
  • Qt — 子窗体操作父窗体中的方法

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

    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(); 
          }
    }
  • 相关阅读:
    9.17
    9.14
    9.13
    9.13
    9.11
    9.28
    10 .19 知识点
    redux
    react路由
    react的三大属性
  • 原文地址:https://www.cnblogs.com/guolebin7/p/3511058.html
Copyright © 2011-2022 走看看