简体   繁体   中英

What is the proper way to create Cancel Button that closes dialog in GTK+?

The question is for GTK+ programing in C++. I have a main window with a button that activates a dialog window. The dialog window has OK and CANCEL buttons. I did it that way so when I hit the cancel button the dialog is closed. But once it is closed I cannot call it again with the button in the main window.

I have tried to call the dialog delete-event on the button click. I also tried to call the dialog destroy event when the button is clicked. But in both cases the dialog is destroyed and it does not show when I click the button that calls the dialog.

I suppose this is a follow up of your other question on the topic: How to properly close a dialog made in Glade?

If it was created using GtkBuilder , if you destroy the window, it's really destroyed: GtkBuilder has created the widgets at parsing time, not when you call get_object , and won't create them again. So I think you should just hide the dialog with something like gtk_widget_hide_on_delete , and show it again when you click on the button in your main dialog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM