简体   繁体   中英

How do I get the gdk window for a gtk window in C?

I'm trying to set the cursor to a watch. The problem is that gdk_set_cursor() requires a gdk_window.

How do I get the gdk_window of a gtk_window in C? I've seen examples for gtkmm and pygtk but I can't find the corresponding C function.

GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(gtk_window));

或者,在GTK 2.14之前,但现在不允许:

GdkWindow *gdk_window = gtk_window->window;

In my case gdk_window_set_cursor did not work because gtk_widget_get_window was returning an invalid handle because it was not already realized. Moving those lines after the window is made visible solved it for me.

From docs:

... For example, widget->window will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM