toolbaritems
has been deprecated in Ubuntu.Components 1.1
, so its use is strongly discouraged. It is maintained for backward compatibility, but the right way to add items to the header toolbar is now using head.actions
.
The main difference between head.actions
and toolbaritems
is that you don't need anymore to add ToolbarButton
items and then set their action
property. All you need with head.actions
is to specify a list of actions and then they will be automatically shown according to Ubuntu Touch patterns.
An example that shows how to use head
property is the following (from official documentation):
import QtQuick 2.0
import Ubuntu.Components 1.1
MainView {
width: units.gu(48)
height: units.gu(60)
Page {
title: i18n.tr("Example page")
Label {
anchors.centerIn: parent
text: i18n.tr("Hello world!")
}
head.actions: [
Action {
iconName: "search"
text: i18n.tr("Search")
},
Action {
iconName: "contacts"
text: i18n.tr("Contacts")
}
]
}
}
There are some other useful settings for PageHead
(e.g. custom Item
to show instead of the title), so I'd suggest you to take a look at this page.
If you are running Ubuntu 14.04 LTS, these new APIs are not available, due to their dependence on Qt 5.3. You can solve this issue following this link .