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;
}
此種情況下,會先顯示對話框,此時不執行指針對應對象的析構函數,直到點擊關閉對話框后,析構函數才會執行
?
轉載于:https://www.cnblogs.com/vector-wei/p/5354162.html
總結
以上是生活随笔為你收集整理的Arm开发板+Qt学习之路-析构函数和对话框一起时的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用BlazeMeter录制JMeter测
- 下一篇: web.xml中相关标签的加载顺序