需求是在关机或重启时停掉外部设备。
用的最新版本的5.14.0,Qt Creator, MingW64。
尝试了qApp的aboutToQuit信号,发现关机重启时没有触发(测试代码是写log)。从手册看似乎应该能触发:
This may happen either after a call to quit() from inside the application or when the user shuts down the entire desktop session.
测试代码,在main函数里挂了个slot:
QApplication a(argc, argv);
MainWindow w;
w.show();
QObject::connect(qApp, &QApplication::aboutToQuit, &w, &MainWindow::onQuit);
是用的不对吗?
--
FROM 124.193.78.*