Re: typecast from Gtk::Widget to Gtk::Toolbar?



Jonathon is right, my method (which harks back to my many years as a plain "C" programmer) would result in a serious error if not an outright segmentation fault if the cast were invalid. Sorry about that guys.

Bob

ZeeGeek wrote:

On 1/11/06, Jonathon Jongsma <jonathon jongsma gmail com> wrote:
There's probably not much difference here practically speaking.
Theoretically dynamic_cast might be safer since it does some run-time
type-checking to make sure that the cast is legal.  dynamic_cast is
"the C++ way", but the other way is still valid.

Jonner

thank you.

On 1/10/06, ZeeGeek <zeegeek gmail com> wrote:
On 1/11/06, Bob Caryl <bob fis-cal com> wrote:
You should be able to write something like:

Gtk::UIManager ui;
// ui has been initialized somewhere in between
Gtk::Toolbar *mytoolbar =  (Gtk::Toolbar *)ui.get_widget("/Toolbar");

since Gtk::Toolbar is descended from Gtk::Widget, but be sure to check
that the returned pointer is not NULL before using it.

B.Hakvoort <bart hakvoort be> wrote:
maybe with a Gtk::Toolbar * p_toolbar =
dynamic_cast<Gtk::Toolbar
*>( Gtk::UIManager::get_widget("/Toolbar") ) ; ?
Both method work, thank you all!
Is there any differences between these two methods?

--
My blog: http://ihome.ust.hk/~cs_snx/blog/

Dell Inspiron 600m
Pentium-M 1.6G
512MB, 60G
ATI 9000 Mobility
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



--
My blog: http://ihome.ust.hk/~cs_snx/blog/

Dell Inspiron 600m
Pentium-M 1.6G
512MB, 60G
ATI 9000 Mobility
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



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