Image
Object Hierarchy:
Description:
[ CCode ( type_id = "gtk_image_get_type ()" ) ]
public class Image : Widget, Accessible, Buildable, ConstraintTarget
public class Image : Widget, Accessible, Buildable, ConstraintTarget
The Image widget displays an image.
Various kinds of object can be displayed as an image; most typically, you would load a Texture from a file, and then display that. There’s a convenience function to do this, Image.from_file, used as follows:
GtkWidget *image;
image = gtk_image_new_from_file ("myfile.png");
If the file isn’t loaded successfully, the image will contain a “broken image” icon similar to that used in many web browsers. If you
want to handle errors in loading the file yourself, for example by displaying an error message, then load the image with
from_file, then create the Image with
Image.from_paintable.
Sometimes an application will want to avoid depending on external data files, such as image files. See the documentation of Resource for details. In this case, the resource, Image.from_resource and set_from_resource should be used.
CSS nodes
GtkImage has a single CSS node with the name image. The style classes .normal-icons or .large-icons may appear, depending on the icon_size property.
Accessibility
GtkImage uses the IMG role.
Namespace: Gtk
Package: gtk4
Content:
Properties:
Creation methods:
Methods:
Inherited Members:
All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object
All known members inherited from interface Gtk.Accessible
All known members inherited from interface Gtk.Buildable