Reputation: 41
I have the following code
class XMenu: public Gio::Menu
{
public:
XMenu();
};
class App : public Gtk::Window
{
public:
App();
protected :
Gtk::Button btn;
XMenu menu;
};
XMenu::XMenu()
{
append("option1", "app.option1");
append("Quit", "app.quit");
}
App::App()
{
set_default_size(600,600);
btn.set_label("Hello");
//auto casted_menu = dynamic_cast<Gtk::Widget&>(menu);
set_child(casted_menu);
}
As you can see I have two custom class one inherits from Gio::Menu
the other from Gtk::Window
, the goal is to create a menu bar in the App GUI by using a custom menubar created using the XMenu class, when set_child
is commented the code compiles without errors but when uncommented the following error is thrown
main.cc:33:19: error: cannot convert ‘XMenu’ to ‘Gtk::Widget&’
33 | set_child(menu);
| ^~~~
| |
| XMenu
How can I use this custom menubar in a GUI application?
If I understand correctly this states that XMenu should be a Widget in order to be added, so I tried dynamically casting it into a widget but didn't help
Upvotes: 0
Views: 77