Can't execute the gtkmm example code

Hi there!

I’m trying to learn gtkmm (using ubuntu) and I’m starting with the gnome tutorials.

I’ve started with this code

 #include <gtkmm.h>

class MyWindow : public Gtk::Window
{
public:
  MyWindow();
};

MyWindow::MyWindow()
{
  set_title("Basic application");
  set_default_size(200, 200);
}

int main(int argc, char* argv[])
{
  auto app = Gtk::Application::create("org.gtkmm.examples.base");

  return app->make_window_and_run<MyWindow>(argc, argv);
}

It compiles fine with g++ via terminal but when I try to execute it I get this error:

(process:12254): Gtk-CRITICAL **: (number): _gtk_style_provider_private_get_settings: assertion ‘GTK_IS_STYLE_PROVIDER_PRIVATE (provider)’ failed

I can’t understand what this is and I can’t find any reference in internet.

Anyone can give any help?

Thank you a lot

Where is make_window_and_run?

The code you posted is just the boilerplate provided by gtkmm:
https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-basics-simple-example.html.en

Is there a legitimate question or not?

Ciao.

Just in case someone, someday try to compile this code (as is written in the Gtkmm official tutorials) just make sure that you are using gtkmm4.

The problem was that I was trying to compile this code with gtkmm3.

Also, you need to know that it is not mandatory to use inheritance or pass your class as a template argument.
Here’s a simpler version of your code:

#include <gtkmm-4.0/gtkmm.h>

using namespace Gtk;

int main(int argc , char** argv){
    auto app = Application::create("org.gtk.example");
    Window window;

    window.set_title("Gtk4 Demo");
    window.set_default_size(300 , 400);
    app->signal_activate().connect([&](){
        app->add_window(window);
        window.show_all_children();
    });

    app->run(argc , argv);

    return 0;
}

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