How to bind a GTKWindow in C++ code to the .UI file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to bind a GTKWindow in C++ code to the .UI file

Arvind Arvind Pro
Hi
 
I have a .UI file where a window with some custom widgets is declared.
Now the main window is named "main_win"
 
This is how the UI file is initialized in the main function of the application- the path+ name of UI
file is stored in the constant named "UI"
 
//Load the Glade file and instiate its widgets:
    Glib::RefPtr<Gtk::Builder> builder;
    try
    {
        builder = Gtk::Builder::create_from_file(UI);
    }
    catch (const Glib::FileError & ex)
    {
        std::cerr << ex.what() << std::endl;
        return 1;
    }
    Gtk::Window* main_win = 0;
 
Now, my question is this-
 
How to link the GTK Window variable declared above- "main_win" with the window in the UI file and initialise it to show everything? I am sorry if this sounds like a newbie question :)
Any help would be appreciated:)
 
Yours sincerely,
Arvind.

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How to bind a GTKWindow in C++ code to the .UI file

Gtkmm mailing list
Try with:

builder->get_widget("main_win", main_win);
if (main_win == nullptr) {
  /* handle error */
}

Gtk::Builder::get_widget() method reference:

Have a look here for a detailed guide:

Il gio 23 mag 2019, 12:59 Arvind Arvind Pro <[hidden email]> ha scritto:
Hi
 
I have a .UI file where a window with some custom widgets is declared.
Now the main window is named "main_win"
 
This is how the UI file is initialized in the main function of the application- the path+ name of UI
file is stored in the constant named "UI"
 
//Load the Glade file and instiate its widgets:
    Glib::RefPtr<Gtk::Builder> builder;
    try
    {
        builder = Gtk::Builder::create_from_file(UI);
    }
    catch (const Glib::FileError & ex)
    {
        std::cerr << ex.what() << std::endl;
        return 1;
    }
    Gtk::Window* main_win = 0;
 
Now, my question is this-
 
How to link the GTK Window variable declared above- "main_win" with the window in the UI file and initialise it to show everything? I am sorry if this sounds like a newbie question :)
Any help would be appreciated:)
 
Yours sincerely,
Arvind.
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list