Qt World Summit: Submit your Presentation

Dynamically Setting the Tools in a ToolBar

  • Hello,

    I am developing a mobile app for iOS and I need to be able to have the tools in the toolbar change depending on which page you are on. I found some documentation on how to accomplish this but it looks like it is out of date and the components and methods needed to accomplish this no longer exist.

    This is the document I found: https://doc.qt.io/archives/qtquick-components-symbian-1.1/qml-toolbar.html

    It mentions using the following Components and Methods that seem to be gone now in QT 5.7:

    setTools() method.

    Is there a newer way of acomplishing dynamic tools in a ToolBar?

    Thanks for any help on this,


  • Hi! There are many ways to do that. But as you said your application uses multiple pages than you can simply use the Page QML Type which has a property header. So each page can have its own ToolBar assigned to header.

  • @Wieland I do that now with StackViews and I have multiple toolbars. I was trying to get away from having multiple toolbars inside of each StackView and put one ToolBar in the main window and then have the controls in the toolbar change dynamically depending on which StackView you are in.

    I guess the only way is to make my own toolbar and methods to change the visibility of the buttons per page I am on.

  • This too seems like a regular "State-Transition" problem?

    In one state you want to handle toolbar x, and in another state you want to handle toolbar y?

    See documentation about states and transitions.

Log in to reply