May 2019
Intermediate to advanced
542 pages
13h 37m
English
A toolbar is a long row of buttons often used for editing commands or similar actions. Unlike main menus, toolbars are not hierarchical and the buttons are typically only labeled with an icon.
QMainWindow allows us to add multiple toolbars to our application using the addToolBar() method, like so:
toolbar = self.addToolBar('File')
The addToolBar() method creates and returns a QToolBar object. The string passed into the method becomes the toolbar's title.
We can add QAction objects much like we can to a QMenu object:
toolbar.addAction(open_action) toolbar.addAction("Save")
Just as with a menu, we can add QAction objects or just the information to build an action (title, callback, and other).
Run the application; it should ...
Read now
Unlock full access