Re: Creating widgets at runtime
- From: Ondřej Tůma <konference webjet cz>
- To: gtkmm-list gnome org
- Subject: Re: Creating widgets at runtime
- Date: Mon, 11 Sep 2006 14:41:21 +0200
Hi, the simplest way ho to do it, is with dynamic allocations. So
Gtk::Button* button = new Gtk::Button('Dynamic Button');
when you create button by this way, you must call delete after
destroying the HBox for example. If u want to destructor call this
automaticly, you must create object by this way:
Gtk::Button* button = manage (new Gtk::Button('Dynamic Button'));
More about this technique is on Tutorial on Chapter 18. Memory management.
On Fri, 8 Sep 2006 23:16:02 -0700 (PDT)
andypaxo <nabble andypaxo net> wrote:
>
> I have a little experience with gtkmm, but just trying something new at the
> moment...
>
> I'm trying to add widgets to a program at runtime (as a simple example,
> adding buttons to an HBox in response to user input). However I'm not
> getting very far.
>
> Having tried several approaches and having scoured the internet and the docs
> for some time, I am getting nowhere.
>
> WARNING: There's a high probability that I'm really over-complicating things
> here
> (You most likely don't want to read this bit!)
> - My first thought was to simply declare a new button in a method and add
> it to the HBox as you would with a member variable button, but nothing
> appears
> - My second thought was to create a std::vector containing
> Glib::RefPtr<Gtk::Button> objects (in order to hold onto the button after
> the method call had ended);
> However, there seems to be no way to add the RefPtr object to an HBox
> (and no way to add a plain button to a vector)
>
> So, if anyone knows a way to generate widgets at runtime, it would be great
> to hear it,
--
Ondrej Tuma
Unix-like system is the best operation system from the top of the world.
I'm lucky BSD and linux user. :) Use unix-like, be free. :)
www.blackmouse.biz www.radioakropolis.cz hash.webjet.cz
ICQ: 107760454 JABBER: mcbig jabber cz MSN: ondra tu atlas cz
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]