Re: [gtkmm] Change cursor in Widget (fwd)



Now it works, with the call to Gtk::Window::on_realize() before the call 
to the cursor functions

virtual void on_realize(){
                Gtk::Window::on_realize();
                Gdk::Cursor cursor(Gdk::STAR);
                get_window()->set_cursor(cursor);
}

Thanks

Sergio Pascual wrote:
>>>Hi, I'm trying to change the cursor over one window. I'm using this simple 
>>>code, but it segfaults:
> #include <gtkmm/window.h>
> #include <gtkmm/main.h>
> #include <gdkmm/cursor.h>
> 
> class CWindow: public Gtk::Window{
> 	public:
> 	CWindow(){};
> 	~CWindow(){};
> 	protected:
> 	virtual void on_realize(){
Sergio, if you place
         Gtk::Window::on_realize()
here, your code should work.

> 		Gdk::Cursor cursor(Gdk::STAR);
> 	        get_window()->set_cursor(cursor);
> //        while(Gtk::Main::events_pending())
> //          Gtk::Main::iteration();
And do not forget to remove next line
> 		Gtk::Window::on_realize();

> 	}
> 	
> };
> 
> int main (int argc,char **argv){
> 	try{
> 	Gtk::Main app(argc,argv);
> 	CWindow window;	
> 	app.run(window);
> 	}
> 	catch(const Glib::Error& error){
> 	  g_warning("%s",error.what().c_str());
> 	}
> 	return 0;
> }

--
fuxx




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