Search code examples
c++user-interfacegtkgtkmm

Gtkmm 3.0 How to switch between frames or windows


I'm rather new to C++, I have a bit of experience with MCV programming in Java. im using GTKmm on C++ What I'm trying to do is writing an application for teaching assistants to submit and edit applications to various positions, and administrators to come in view, and accept these applications.

What I'm trying to do at the begging is create 3 'frames' (I'm working on the submitting application for students only at the moment)

  • This first will have 2 buttons 1 for selecting if you're a student/admin

  • Upon clicking you're a student I want to hide this frame and show my second frame

  • The second frame will have another 2 buttons one for creating an application, and the other for editing applications

My core problem is that I don't understand how to switch between the frames, I've written all the code for my Model, and understand everything I want it to do however I cant seem to find how to do this...

My only idea would be to create windows for each of these, make them look all nice w/e, then when a button is pressed have that window close and a string written to file I can access to see which button has been pressed, then open a new window accordingly. Should I do it like this or is there a better way?


Solution

  • Easiest way is to use a Notebook widget. You can hide the tabs since you will be controlling which page is showing, using method set_show_tabs(false). Put the top level widget for each of your frames in a pane using method append_page(), and switch between them using set_current_page(). You might want to hide the notebook's bevel if it's distracting, using method set_show_bevel(false).

    Use signals to make a widget (e.g. "I'm a student" button) on one page do something (e.g. go to the second page). If you don't know what this means or how to do it, go through the gtkmm tutorial, it will explain this and more.