我已经为窗口的"file"->“退出”按钮编写了一个事件处理程序:
void on_file_quit() {
int err = pthread_cancel( work );
if (err) {
std::cerr << "no thread to cancel\n";
}
else {
pthread_join( work, NULL );
}
}
以这种方式实例化它:
pfile_quit->signal_activate().connect( sigc::ptr_fun(on_file_quit) );
我想在 on_file_quit() 结束时关闭窗口,就像按下窗口顶部的关闭按钮一样。我在任何地方都没有找到解决方案。预先感谢您的帮助!
最佳答案
您可以使用 Gtk::Widget::hide() 关闭窗口。如果您想要执行与单击 X 按钮(发送 delete_event 信号)时发生的相同操作,只需直接调用 on_delete_event() 处理程序即可。
顺便说一句,您没有“实例化”信号处理程序。您正在连接一个信号处理程序。另外,这是 gtkmm,而不是 GTK+。
关于c - GTK 默认文件->退出行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11420235/