Initialize `background-image` with an image from resource in gtkmm

Hello, assume I created a gtk app with a label which i sytled it using background-color using the Gtk::CssProvider like this:

pseudo-code

MainWindow::MainWindow():
MyLabel("Hello")
{
    provider = Gtk::CssProvider::create();
    provider->load_from_data(
    "#BackgroundImage{"
    "background-image:url(\"file:///home/user/Desktop/sonbg.jpg\");"
    "background-size:100% 100%;"
    "opacity:0.3;"
    "}"
    );
    MyLabel.set_name("BackgroundImage");
    MyLabel.get_style_context()->add_provider(provider, 1);
}

everything is perfect but i dont know how to set the background-image in my css string to get the image from reource. Please Help me. Thank you.

add the resources properly to the project and interact with them using resource prefix like this:
background-image:url("resource:///org/custom/example/sonbg.jpg");
Thank you Andrew.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.