当我要退出应用程序时,如何在QT中自动调用destructor
How automatically call destructor in qt when I want to exit the application?
i使用CAMA系列(手指打印模块)作为我的应用程序。在该文档中说,建议在退出应用程序之前使用EnrollStandByMode
命令。我创建此命令,并在应用程序中的qmainwindow上的destructor中称其为。(这里没有问题)。但是,当我退出应用程序并再次运行时,我的手指打印会混淆,并且响应命令不正确。跟踪我的代码后,我看到destructor在应用程序关闭时未运行。
这是我退出QAPP的代码。
void MainWindow::on_pushButton_clicked()
{
qDebug()«"QApplication::quit()";
QApplication::quit();
}
我想知道如何在退出应用程序之前致电Destructor?
在应用程序末尾有几种调用某些东西的方法。
如果您的代码不需要QT事件循环运行,只需在main()
int main(int argc, char **argv)
{
QApplication app(argc, argv); // or QGuiApplication/QCoreApplication
// application setup
const int resultCode = app.exec();
// call your shutdown code here
return resultCode;
}
另一个选项是用qAddPostRoutine()
注册函数,该功能由QT应用程序对象的destructor调用。
如果您需要QT事件循环,请将功能连接到QT应用程序对象的aboutToQuit()
信号。
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用Qt C++计算类似Git的SHA1哈希
- Qt focusObjectChanged example?
- 如何在cpp文件之间切换窗口?在Qt中
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- Qt和C++:将QLineEdit添加到QTabWidget中
- 从数据库实时显示QT c++中的数据
- Qt Quick-如何仅从c++代码与qml属性交互
- 无法使用Qt Creator在Windows中构建yaml-cpp
- 如何在Qt中取消捕获字符串
- 当我要退出应用程序时,如何在QT中自动调用destructor