Styled tool item container with page synchronized transitions More...
Inherits Item
This element was introduced in qt-components 4.7.
The ToolBar can be used either with or without the PageStack. Logically the toolbar is split into three levels:
Using the toolbar is a simple matter of specifying the tools - as a single QML item - with the tools property of the ToolBar item. This single QML item is typically the tool container (level #3 according to the definition above) and contains items (level #2 above) that are the actual tools.
When the tools property changes the ToolBar performs a transition animation between the old and new tools. The transition that is used is specified using the transition property. By default this is "set", which means an immediate change of tools without any animation. Other supported transitions are "push", "pop" and "replace", which correspond to the page stack navigation methods.
The tools can also be changed with a particular transition using the setTools() method. The first argument of this function is the new tools and the second is the transition to use. The tools property of the ToolBar will be updated as a result of calling this method but the transition property will remain unchanged. That is, the transition that is specified in setTools() applies only to this particular change of tools rather than all subsequent changes.
The tools that are in the toolbar for a particular page are defined using the tools property in a page. When the toolbar property of the PageStack references a particular toolbar then whenever a page is activated its tools properties are set to that toolbar using the same transition that was used to activate that page. For example a push() call in the PageStack results in the tools being changed in the toolbar using the "push" transition.
A typical tools definition in a page would look something like this:
Page { tools: ToolBarLayout { ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); } ToolButton { text: "One" } ToolButton { text: "Two" } ToolItem { iconId: "icon-m-toolbar-view-menu" } } }
When used without the PageStack the tools are defined exactly the same way but in the application instead of in the page. Instead of automatically being set to the toolbar, you have to manually set the tools property of the toolbar to refer to the property or id that defines the new tools, as follows:
Rectangle { someTools: ToolBarLayout { ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); } ToolButton { text: "One" } ToolButton { text: "Two" } ToolItem { iconId: "icon-m-toolbar-view-menu" } } ToolBar { id: toolBar transition: "replace" tools: ToolBarLayout { ToolButton { text: "Old One" } ToolButton { text: "Old Two" } } } Button { text: "Change Tools" onclicked: toolBar.tools = someTools } }
In the example above the tools are changed when the button is pressed. The tool bar would perform a "replace" transition animation between the old tools (buttons "Old One" and "Old Two") and the new tools defined by someTools.
Platform specific property to define the style of the toolbar. Note this property is not cross-platform.
See also ToolBarStyle.
tools : Item |
Property default is null.
Tools to show on the toolbar. Normally do use a Layout item.
transition : string |
Property default is "set".
The transition type is one of the following:
ToolBar::setTools ( tools, transition ) |
Sets the tools with a transition.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.