zoukankan      html  css  js  c++  java
  • Arm开发板+Qt学习之路-析构函数和对话框一起时

    先记录一下代码

    一:先将指针释放掉,在显示对话框

    void MainWindow::canResponseError(SendCanMsgThread *sendCanMsgThread ){

    std::cerr<<" canResponseError "<<std::endl;
    delete sendCanMsgThread;
    sendCanMsgThread = NULL;

    QMessageBox msgBox;
    msgBox.setText("Could not get can response " );
    msgBox.exec();

    }

    此种情况下,先执行指针对应对象的析构函数,再执行对话框的显示

    二:先显示对话框,再释放掉指针

    void MainWindow::canResponseError(SendCanMsgThread *sendCanMsgThread ){

    std::cerr<<" canResponseError "<<std::endl;
    QMessageBox msgBox;

    msgBox.setText("Could not get can response " );
    msgBox.exec();

    delete sendCanMsgThread;

    sendCanMsgThread = NULL;

    }

    此种情况下,会先显示对话框,此时不执行指针对应对象的析构函数,直到点击关闭对话框后,析构函数才会执行

  • 相关阅读:
    BBS项目
    form组件
    auth模块
    模板语言
    内置auth 的使用,用超级用户创建
    django文件上传
    django序列化问题
    SPI Flash的操作
    输入捕获实验
    uc os相关的C语言知识点1-函数指针
  • 原文地址:https://www.cnblogs.com/vector-wei/p/5354162.html
Copyright © 2011-2022 走看看