Adding side bar to browser
I would like to add a 'side bar' to my browser that allows the user to access additional functionality like downloads, history, etc. I would like to create a button, that, when toggled added the sidebar widget to the left side of the application. Because this entire area is already taken up by a webView, the webView would need to shrink to accommodate the new side view. The concept is similar to the bookmarks/reading list side bar on Apple's Safari. The sidebar would be created and destroyed by a button that could be toggled.
How can I create a sidebar that can appear/disappear based on a toggled button, and when it is present the webView recedes from the left so as not to obscure it/be obscured by it.
Example code would be nice!
Take a look at "QMainWindow":http://qt-project.org/doc/qt-5.1/qtwidgets/qmainwindow.html and "QDockWidget":http://qt-project.org/doc/qt-5.1/qtwidgets/qdockwidget.html and this "example":http://qt-project.org/doc/qt-5.1/qtwidgets/mainwindows-dockwidgets.html.
Make your browser a central widget and the sidebars would be docks. These can be configured to stay in place or be movable and can be toggled via associated "QAction":http://qt-project.org/doc/qt-5.1/qtwidgets/qdockwidget.html#toggleViewAction.
thats an interesting concept. Would it be possible to have the sidebar be a QWebView that could render a website?
ok so I've followed your advice and used a dock widget. how can I make it appear/dissapear when I toggle a button?
code examples would be cool!
If you use a default project template a main window with toolbar and a status bar is created. Otherwise add them yourself.
Then add the dock widget. Use the toggleViewAction() method I mentioned to get an action pointer. Add that action to the toolbar (you might want to add an icon to it first). Nothing more is needed. Actions added to toolbar appear as buttons, and added to menu as, well, menu items. The action is already toggle'able so if you click on it in the toolbar it will show/hide the panel.
For code examples browse through the official Qt ones like the one I posted. It shows this use of toggleViewAction, except it adds it to the main menu, not the toolbar.
As for the contents of a dock it can be any widget, including webview.
Ok so would this work?
button = new QToolButton;