Re: GTK Custom Widgets



Guillaume Brocker wrote:
> Filipe Apostolo a écrit :
>> Hi everybody,
>>
>> I'm trying to do a custom widget to use in more than one app.
>> So I've build a class "MyWidget" derived from  Gtk ::Widget :
>>
>> class MyWidget : public Gtk::Widget
>> {
>> public:
>>   MyWidget();
>>   virtual ~MyWidget();
>>
>> protected:
>>
>>   //some Overrides virtual functions
>> (...)
>>
>>  Gtk::Hbox mMyHbox_to_add_in_my_widget;
>> };
>>
>> But the problem is that I don't know how to add the HBox in my custom
>> widget.
>>
>> So I've looked the
>> http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-custom-widgets.html
>>
>> tutorial but it doesn't explain how to add a child widget into a custom
>> widget.
>>
>> The purpose of adding the Hbox is to heave a kind of container to
>> start adding other widgets like treeviews, buttons, combo boxes  and
>> so one.
>> And I don't want to derive from a container or from a window.
>>
>> Can some wane help me, is it possible ore there are more efficient ways
>> to do something like this?
>
> Two possible solutions :
> - make your widget inherit from Gtk::HBox
> - make your widget inherit from Gtk::Bin, and then add the Gkt::HBox
> in the constructor of your widget
Can you provide me a link with a example of using Gtk::Bin, I only find
Class reference.

Tanks
>
> Guillaume
>
>



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