处理中断时如何返回主 GUI 线程?

How to get back to main GUI thread when handling an interrupt?

我有一个 Raspberry Pi 3 运行 一个用 Qt 编写的 GUI 程序。我正在使用 wiringPi library 设置在某个 GPIO 引脚变低时触发的中断。发生这种情况时,我希望出现一个对话框 window 告诉用户 Pi 将在 10 秒后关闭,在此期间他们可以选择取消关闭。

问题是接收中断的函数是在新线程中启动的,Qt不允许在主线程外使用定时器等。我想知道如何从中断函数返回主线程。该函数不接受任何参数,顺便说一句。

示例代码:

MainWindow::MainWindow() {
    wiringPiSetup();
    //Set up an interrupt to detect when WiringPI pin 0 (header #11) goes low
    //Call the ShutdownISR function when this happens.
    wiringPiISR(0, INT_EDGE_FALLING, &ShutdownISR);
}

//Non-member, free function. Handles interrupt.
void ShutdownISR() {
    //Crashes the program with errors about doing GUI stuff outside the main thread
    ShutdownDialog* sdDlg = new ShutdownDialog();
    sdDlg->exec();
} 

AFAIU interrupts are only handled by the Linux kernel and are not directly visible to application code. However, be aware of unix signals and read signal(7) & signal-safety(7) & Advanced Linux Programming & Operating Systems : Three Easy Pieces

关于Qt和信号,有文档;见 Calling Qt Functions From Unix Signal Handlers