sorry for the probably pretty easy question, but after a couple hours I still have no idea what the problem.
I have a UI file made in Glade, inside said UI file somewhere there is a Box with an id. Inside said box I need to add and remove widgets dynamically (it will end up being an image previewer).
I managed to make this work in Python by doing the following (this was a prototype)
window = builder.get_object("window1") pictureFrame = builder.get_object("PreviewBox") pictureFrame.pack_start(PictureView(scanner.collectionPictures), True, True, 0) window.show_all()
Now I’m trying to make the full application in Cpp, but when doing the following:
Gtk::Box* previewBox; insertData_Builder->get_widget<Gtk::Box>("PreviewBox", previewBox); Gtk::Label label = Gtk::Label("test label"); previewBox->pack_start(label, true, true, 0);
the widget won’t show up, on further inspection using the GTK Inspector, I did find out that in fact there is no widget inside the
I did call
.show_all() on the top level, however in another function (even thought, since the widget is not actually present that is definitely not the problem).
Essentially, this should be the same code, but no dice.
As a side note
I have noticed another major difference that I belive could be related to this issue when moving from Python to C++.
In Python whenever I was getting a Window from a builder to then destroy it, I needed to get a callback on the destroy event signal, to prevent the window from beign destroyed and instead hide it, otherwise re opening (or rather, showing) the window would show an empty window.
In C++ instead there is no need to do any of this, and I believe this is related because it almost feel like in Python you can edit widgets inside a builder loaded from a UI file, while in C++ you cannot, thought, this doesn’t make much sense.
Thank’s in advance for any help!
As a comment that I forgot to add.
From my (potentially completely wrong) understanding, Gtk::Builder creates an instance of every widget inside the XML… it almost feels like
Gtk::Builder::get_widget() returns a copy of said widget rather than a reference of the widget that will get drawn, while in Python a reference to the widget to be drawn is returned.
Is this assumption correct? And if so, how could I access to the widget directly stored within Builder that will actually be drawn?