GtkDialog mapped without a transient parent. This is discouraged

    Gtk::Dialog  test;
    test.set_parent(*this);
    test.show();

This is the code in parent window and can’t create the dialog.

You want GtkWindow.set_transient_for, not GtkWidget.set_parent.

1 Like

And how to get the GDK::window from Gtk::Window?
I use gtkmm4, sorry for my murmur.

The method I linked uses GtkWindow, not GdkWindow.

In GTK4 there’s no GdkWindow either: it’s been renamed GdkSurface.

Oh, thank you, cause I learn the lava first with GTK3+…
So, how to get the window from the widget… /(ㄒoㄒ)/~~

You really need to read the documentation for GTKmm.

GtkDialog inherits from GtkWindow, so any method on GtkWindow will work on GtkDialog.

If you have a dialog, you’ll need to set its transient parent—usually, the main application window. If you’re presenting a dialog in a signal handler like a “clicked” signal for a GtkButton, you can retrieve the containing window by using something like:

  GtkWidget *ancestor =
    gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);

Again: you’ll have to read the GTKmm bindings documentation.

1 Like

HaHa, sorry for the rookie problem…
And thank you for your help…

The behavior of Gtk’s dialog is different with MFC…
I thought the test.show() would block the workflow instantly…, but it’s not in GTK4.
So, the mistake of mine which can’t show the dialog: Dialog should not be the temporary variable…

Thank you for your patient!!!

    //Gtk::Dialog  test;// 
    //test.set_transient_for( *((Gtk::Window*)get_ancestor(GTK_TYPE_WINDOW)) );
    test.set_modal(true);
    test.show();

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.