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



Try with:

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

Gtk::Builder::get_widget() method reference:
https://developer.gnome.org/gtkmm/stable/classGtk_1_1Builder.html#ae525dfa187377dcdc1179a52df3d160a

Have a look here for a detailed guide:
https://developer.gnome.org/gtkmm-tutorial/stable/sec-builder-accessing-widgets.html.en

Il gio 23 mag 2019, 12:59 Arvind Arvind Pro <arvind_dev arvind pro> 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
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]