Adding a widget (in code) to a Glade-derived window



Hi,

I think I'm missing something obvious here...

I create a Gtk::Window with a Gtk::VBox in it using Glade. Then in my code I create a Gtk::Label and try to pack_start it into my Builder-instantiated window. But nothing is shown but an empty window!!�

Here is the sample code, which does not show any label, as I would expect...

#include <gtkmm.h>
#include <gtkglmm.h>

class gui_main : public Gtk::Window
{
public:
gui_main( BaseObjectType*, const Glib::RefPtr<Gtk::Builder> & );
~gui_main(){}
};

gui_main::gui_main(
BaseObjectType*cwindow,
const Glib::RefPtr<Gtk::Builder> & builder )
:Gtk::Window( cwindow )
{
Gtk::VBox * vbox;
builder->get_widget( "vbox1", vbox );

Gtk::Label label1( "blah1" );
vbox->pack_start( label1, true, true, 10 );
label1.show();

//show_all_children();
//show();
}

#include <gtkmm/main.h>

int main( int argc, char**argv )
{
� � Gtk::Main kit( argc, argv );

� � Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
� � refBuilder->add_from_file( "/home/samuel/test_window.glade" );

� � gui_main* gui;
� � refBuilder->get_widget_derived( "window1", gui );

� � kit.run( *gui );
� � return 0;
}

(Of course in my real program I won't be packing a label, but some custom widget, which inherits from Gtk::GL::DrawingArea...)

Best regards
Samuel



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