Unable to display PNG image from file in Gtk::Window

I am having some trouble displaying a PNG file in a Gtk::Window. I tried creating a Gtk::Pixbuf from the file and then create a Gtk::Image using that. Then I tried adding the Gtk::Image to the Gtk::Window but all I’m getting a blank screen. What am I doing wrong?

class CMainWindow : public Gtk::ApplicationWindow
{
public:
    CMainWindow();
    ~CMainWindow();
};

CMainWindow::CMainWindow()
{
    Glib::RefPtr<Gdk::Pixbuf> pic = Gdk::Pixbuf::create_from_file("image.png");
    Gtk::Image* img = Gtk::manage(new Gtk::Image(pic));
    add(*img);
}

CMainWIndow::~CMainWindow() {}

int main(int argc, char** argv)
{
    app = Gtk::Application::create(argc, argv,"org.gtkmm.examples.base");
    CMainWindow c;
    return app->run(c);
}
%d bloggers like this: