Re: Help removing widgets



On Mon, 27 Feb 2006 08:55:22 -0700, Mike <mike geekgene com> wrote:

Hello,

I can't find very much coverage of how this actually should work, and it's
giving me a lot of troubles.  If anyone would help it'd be greatly
appreciated.

I have a program setup with a HPaned in a window. The content in the seccond panel (the right side) needs to be swapped out for another widget when the
user clicks a button.

So far I have tried several different approaches and no matter what I do it either crashes, seems to delete the HPaned but keep the left side, or both.

I've been able to reproduce the behaviour in a simpler case using labels:

class MainWnd : public Gtk::Window
{
protected: // Widgets
	Gtk::HPaned m_hpMainDiv;
	Gtk::Label *m_lRightText;
	Gtk::Button m_btnChange;
	
public:
	void on_change()
	{
		m_hpMainDiv.remove( *m_lRightText );
		delete m_lRightText;
		m_lRightText = new Gtk::Label("New right text...");
		m_hpMainDiv.add2( *m_lRightText );
	}

	// constructor etc omitted...
};

You do correctly remove the old label and add a new one, but you forget
to show the newly added label, adding:
m_hpMainDiv.show_all_children();
after adding the new label will fix that.


There we go, on_change is the handler called when you click the button on the left. I've tried a few different ideas I found searching this mailing list,
including "unparent" and "reference".  Nothing seems to help.

Thanks a lot,
--Mike

P.S. I'm having similar difficulty removing pages from a notebook and adding other pages...this shouldn't be this difficult, I think I'm missing something
fundamental.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list






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