Re: Obtaining widget coordinates relative to window



On Fri, 20 Aug 2010 02:10:58 -0700 (PDT)
RedOctober <stuartvquick yahoo com> wrote:
> Hi,
> 
> I am trying to locate a widget's coordinates relative to its position
> in a displayed window.
> 
> I have created a very simple test layout using glade with a single
> top level window, a fixed layout, containing a single button. The
> layout is loaded and displayed and the program attempts to locate the
> X,Y of the button widget.
> 
> I have tried two methods:
> 
> - Using allocation:
>   Gtk::Button* button = 0;
>   m_refGlade->get_widget("button1", button);
>   assert (button);
>   cout << button->get_allocation().get_x() << " " <<
> button->get_allocation().get_y() << endl;
> 
>   Both X,Y values are always -1.

Probably the button and container haven't been realised at that point in
your code. (That is, your "the layout is loaded and displayed" is
wrong.)

Chris




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