Re: [gtkmm] Change cursor in Widget



I have put the code inside on_realize, but it still segfaults. I have 
attached the code, it is a little bit more elaborated.

I have also searched "cursor" in the FAQ 
(http://gtkmm.sourceforge.net/gtkmm2/docs/FAQ/html/index.html) but it's 
not there


On Mon, 12 May 2003, Maurizio Umberto Puxeddu wrote:

> you have to do that in the on_realize() method override or however when
> the widget's window has already been created
> .
> I think it's also in the FAQ but I'm not sure.
> 
> Maurizio Umberto Puxeddu.
> 
> On Mon, 2003-05-12 at 16:12, 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>
> > 
> > int main (int argc,char **argv){
> >         Gtk::Main app(argc,argv);
> >         Gtk::Window window;
> >         Gdk::Cursor cursor(Gdk::STAR);
> >         window.get_window()->set_cursor(cursor);
> >         app.run(window);
> >         return 0;
> > }
> > 
> > Is this the way to change the cursor? I'm using 
> > gtkmm-2.0.2
> > 
> > -- 
> >  <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> >                  Sergio Pascual Ramírez       spr astrax fis ucm es
> >                Tf: (+34)  91-394-50-18      Fax: (+34)  91-394-46-35
> >                       Dept. Astrofísica Facultad de C.C. Físicas 
> >                           Universidad Complutense de Madrid
> >                                  28040 Madrid (Spain)
> >  ------------------------------------------------------------------------------
> >             Spanish junior researchers fight for employment rights 
> >                            http://www.precarios.org
> >  <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> > 
> > 
> > 
> > _______________________________________________
> > gtkmm-list mailing list
> > gtkmm-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 

-- 
 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
                 Sergio Pascual Ramírez       spr astrax fis ucm es
               Tf: (+34)  91-394-50-18      Fax: (+34)  91-394-46-35
                      Dept. Astrofísica Facultad de C.C. Físicas 
                          Universidad Complutense de Madrid
                                 28040 Madrid (Spain)
 ------------------------------------------------------------------------------
            Spanish junior researchers fight for employment rights 
                           http://www.precarios.org
 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

#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(){
		Gdk::Cursor cursor(Gdk::STAR);
	        get_window()->set_cursor(cursor);
//        while(Gtk::Main::events_pending())
//          Gtk::Main::iteration();
		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;
}


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