我在主窗口中有2个触发器
1.从完全关闭应用程序的菜单中
2.从窗口X按钮中忽略该按钮,仅隐藏该窗口。
我正在使用此信号/插槽
我怎么知道它是从哪里触发的?
在closeEvent
中:
connect(ui->actionQuit, SIGNAL(triggered()),this, SLOT(CloseWin()));
void MainWindow::CloseWin()
{
close();
}
// triggered from the ui->actionQuit amd from the X button
void MainWindow::closeEvent(QCloseEvent *event)
{
// how can i know from where its bean triggered?
hide();
event->ignore();
}
最佳答案
可能有两种解决方案:
QAction
)信号连接到单独的插槽,然后在其中调用qApp->quit()
sender()
方法确定发送信号我希望第一个。
关于c++ - Qt如何找出从哪里触发closeEvent(QCloseEvent * event),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8969396/