
Originally Posted by
darkadept
Second, you could use a QTabWidget or QStackedWidget to make everything happen in the central widget portion of the QMainWindow.
I'd go for that one.
If I include all the code for each action in the QMainWindow I end up having huge amounts of unrelated code.
It depends where you place the code. You can code each "view" as a separate class and embed all action code related to that form in the class. Then you can expose actions from the class in the public API with methods like:
//...
QAction *openFileAction
(){ return _openFileAction;
} // not very safe, but works //...
};
class MyWidget : public QWidget {
//...
QAction *openFileAction(){ return _openFileAction; } // not very safe, but works
//...
};
To copy to clipboard, switch view to plain text mode
Finally you add the widget to the stack widget and add actions to toolbars and menus. You can even do the last part automatically if you implement some introspection mechanism.
To better illustrate what I'm thinking about, take a look at the Kontact program for KDE. When you click on an item in the sidebar it jumps to different "forms" or sections in the program, each with it's own menu's toolbars, etc. So to make a long story short, how do I emulate this functionality "properly" in Qt.
Simply show or hide particular toolbars or actions.
Bookmarks