Re: How to use specific methods with a generic widget pointer?
- From: Hubert Figuiere <hub figuiere net>
- To: Paulo Flabiano Smorigo <pfsmorigo gmail com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: How to use specific methods with a generic widget pointer?
- Date: Tue, 17 Mar 2009 14:36:50 -0400
On 03/17/2009 10:33 AM, Paulo Flabiano Smorigo wrote:
Hello,
What can I do to solve the following error? I need to use a different
kind of pointer?
The code:
Gtk::ToggleButton btnOK;
Gtk::Widget *ptrElement = NULL;
ptrElement =&btnOK;
ptrElement->set_active(true);
The error:
error: ‘class Gtk::Widget’ has no member named ‘set_active’
But why do you want to do that, assigning a pointer to a stack object,
given that as soon as you leave the scope the pointer will be invalid.
Unlike the other said, you'd better use static_cast<> because at that
point you do know that ptrElement points to a Gtk::ToggleButton.
And no it can't guess. C++ is a statically typed, which means that it
needs to know at compile time about the method.
Hub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]