Search code examples
gtk3gtkmm

Hide Gtk::Notebook page content, without hiding the tab


I've got an unusual situation where I want to hide the content of a notebook page until the notebook tab is clicked. I basically want a state where only the notebook tabs are visible.

The problem is, if I hide a notebook page, then its tab is also hidden. I've tried forcing the height of the content to zero (using set_size_request) but that doesn't do it (because set_size_request sets the min height, not the maximum.

How can I hide the content of the pages without the tabs disappearing?


Solution

  • You could put it in a single-child parent widget, such as a Gtk::Alignment, and hide the child, but not the parent.

    Or maybe Gtk::Stack would be simpler: https://developer.gnome.org/gtk3/stable/GtkStack.html