Re: [gtkmm] Gtk::Widget types
- From: Ole Laursen <olau hardworking dk>
- To: gtkmm-list gnome org
- Subject: Re: [gtkmm] Gtk::Widget types
- Date: 27 Feb 2003 20:42:07 +0100
Liza Klerck <liza trdlnk com> writes:
> If I have a Gtk::Widget *, is there a way for me to check what type of
> widget it is ? I am using Gtk2.
>
> For example:
>
> void do_someting (Gtk::Widget *widget)
> {
> if widget is a Gtk::Label then do this ...
> if widget is a Gtk::Button then do this ...
> }
Perhaps something like:
if ((Gtk::Label *label = dynamic_cast<Gtk::Label *>(widget)))
use "label" ...
else if ((Gtk::Button *button = dynamic_cast<Gtk::Button *>(widget)))
use "button" ...
The extra set of outer paranthesis kills a warning from GCC about
using = instead of ==, IIRC.
--
Ole Laursen
http://www.cs.auc.dk/~olau/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]